Class Display
- All Implemented Interfaces:
Proxy
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
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
Modifier and TypeClassDescriptionstatic class
Display.Builder<B extends Display.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theClosedCallback
callback.static interface
Functional interface declaration of theOpenedCallback
callback.static interface
Functional interface declaration of theSeatAddedCallback
callback.static interface
Functional interface declaration of theSeatRemovedCallback
callback.static interface
Functional interface declaration of theSettingChangedCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionDisplay
(MemorySegment address) Create a Display proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected Display
asParent()
Returns this instance as if it were its parent type.void
beep()
Emits a short beep on this Displaystatic Display.Builder
<? extends Display.Builder> builder()
ADisplay.Builder
object constructs aDisplay
with the specified properties.void
close()
Closes the connection to the windowing system for the given display.Creates a newGdkGLContext
for theGdkDisplay
.boolean
deviceIsGrabbed
(Device device) Returnstrue
if there is an ongoing grab ondevice
for this Display.void
emitClosed
(boolean isError) Emits the "closed" signal.void
Emits the "opened" signal.void
emitSeatAdded
(Seat seat) Emits the "seat-added" signal.void
emitSeatRemoved
(Seat seat) Emits the "seat-removed" signal.void
emitSettingChanged
(String setting) Emits the "setting-changed" signal.void
flush()
Flushes any requests queued for the windowing system.Returns aGdkAppLaunchContext
suitable for launching applications on the given display.Gets the clipboard used for copy/paste operations.static Display
Gets the defaultGdkDisplay
.Returns the defaultGdkSeat
for this display.Returns the dma-buf formats that are supported on this display.getMonitorAtSurface
(Surface surface) Gets the monitor in which the largest area ofsurface
resides.Gets the list of monitors associated with this display.getName()
Gets the name of the display.Gets the clipboard used for the primary selection.boolean
getSetting
(String name, Value value) Retrieves a desktop-wide setting such as double-click time for the this Display.Deprecated.static Type
getType()
Get the GType of the Display classboolean
isClosed()
Finds out if the display has been closed.boolean
Returns whether surfaces can reasonably be expected to have their alpha channel drawn correctly on the screen.boolean
isRgba()
Returns whether surfaces on this this Display are created with an alpha channel.Returns the list of seats known to this Display.boolean
mapKeycode
(int keycode, @Nullable Out<KeymapKey[]> keys, @Nullable Out<int[]> keyvals) Returns the keyvals bound tokeycode
.boolean
Obtains a list of keycode/group/level combinations that will generatekeyval
.void
notifyStartupComplete
(String startupId) Deprecated.onClosed
(Display.ClosedCallback handler) Emitted when the connection to the windowing system fordisplay
is closed.onOpened
(Display.OpenedCallback handler) Emitted when the connection to the windowing system fordisplay
is 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 Display
Opens a display.boolean
Checks that OpenGL is available for this Display and ensures that it is properly initialized.void
Deprecated.This function is only useful in very special situations and should not be used by applications.boolean
Returnstrue
if the display supports input shapes.boolean
Returns whether it's possible for a surface to draw outside of the window area.void
sync()
Flushes any requests queued for the windowing system and waits until all requests have been handled.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 aGdkEventKey
into a keyval, effective group, and level.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 aGdkEventKey
into 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, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.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
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, 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
, ornull
if 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 newGdkGLContext
for 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
GdkGLContext
failed,error
will be set. Before using the returnedGdkGLContext
, you will need to callGLContext.makeCurrent()
orGLContext.realize()
.- Returns:
- the newly created
GdkGLContext
- Throws:
GErrorException
- seeGError
-
deviceIsGrabbed
Returnstrue
if there is an ongoing grab ondevice
for this Display.- Parameters:
device
- aGdkDevice
- Returns:
true
if 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 aGdkAppLaunchContext
suitable for launching applications on the given display.- Returns:
- a new
GdkAppLaunchContext
for this Display
-
getClipboard
Gets the clipboard used for copy/paste operations.- Returns:
- the display's clipboard
-
getDefaultSeat
Returns the defaultGdkSeat
for 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
.- Returns:
- a
GdkDmabufFormats
object
-
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
GListModel
ofGdkMonitor
-
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 the this Display.- Parameters:
name
- the name of the settingvalue
- location to store the value of the setting- Returns:
true
if the setting existed and a value was stored invalue
,false
otherwise
-
getStartupNotificationId
Deprecated.Gets the startup notification ID for a Wayland display, ornull
if 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:
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
isRgba()
for whether the display supports an alpha channel.On X11 this function returns whether a compositing manager is compositing on this 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
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. UseisComposited()
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 orfalse
if the display does not support this functionality.
-
listSeats
-
mapKeycode
public boolean mapKeycode(int keycode, @Nullable @Nullable Out<KeymapKey[]> keys, @Nullable @Nullable Out<int[]> keyvals) Returns the keyvals bound tokeycode
.The Nth
GdkKeymapKey
inkeys
is 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 ofGdkKeymapKey
keyvals
- return location for array of keyvals- Returns:
true
if 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.
GdkEventKey
contains agroup
field 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:
true
if 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, anerror
will be set describing the error and this function returnsfalse
.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:
GErrorException
- seeGError
-
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 for this Display.- Parameters:
event
- aGdkEvent
-
supportsInputShapes
public boolean supportsInputShapes()Returnstrue
if the display supports input shapes.This means that
Surface.setInputRegion(org.freedesktop.cairo.Region)
can be used to modify the input shape of surfaces on this Display.On modern displays, this value is always
true
.- Returns:
true
if 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
true
is returned the application decides if it wants to draw shadows. Iffalse
is returned, the compositor decides if it wants to draw shadows.- Returns:
true
if surfaces can draw shadows orfalse
if the display does not support this functionality.
-
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#errorTrapPop
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.
-
translateKey
public boolean translateKey(int keycode, Set<ModifierType> state, int group, @Nullable @Nullable Out<Integer> keyval, @Nullable @Nullable Out<Integer> effectiveGroup, @Nullable @Nullable Out<Integer> level, @Nullable @Nullable Out<Set<ModifierType>> consumed) Translates the contents of aGdkEventKey
into a keyval, effective group, and level.Modifiers that affected the translation and are thus unavailable for application use are returned in
consumedModifiers
.The
effectiveGroup
is the group that was actually used for the translation; some keys such as Enter are not affected by the active keyboard group. Thelevel
is derived fromstate
.consumedModifiers
gives modifiers that should be masked out fromstate
when comparing this key press to a keyboard shortcut. For instance, on a US keyboard, theplus
symbol is shifted, so when comparing a key press to a<Control>plus
accelerator<Shift>
should be masked out.This function should rarely be needed, since
GdkEventKey
already 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:
true
if there was a keyval bound to keycode/state/group.
-
translateKey
public boolean translateKey(int keycode, ModifierType state, int group, @Nullable @Nullable Out<Integer> keyval, @Nullable @Nullable Out<Integer> effectiveGroup, @Nullable @Nullable Out<Integer> level, @Nullable @Nullable Out<ModifierType> consumed) Translates the contents of aGdkEventKey
into a keyval, effective group, and level.Modifiers that affected the translation and are thus unavailable for application use are returned in
consumedModifiers
.The
effectiveGroup
is the group that was actually used for the translation; some keys such as Enter are not affected by the active keyboard group. Thelevel
is derived fromstate
.consumedModifiers
gives modifiers that should be masked out fromstate
when comparing this key press to a keyboard shortcut. For instance, on a US keyboard, theplus
symbol is shifted, so when comparing a key press to a<Control>plus
accelerator<Shift>
should be masked out.This function should rarely be needed, since
GdkEventKey
already 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:
true
if there was a keyval bound to keycode/state/group.
-
onClosed
Emitted when the connection to the windowing system fordisplay
is 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 fordisplay
is 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.Builder
object constructs aDisplay
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withDisplay.Builder.build()
.
-
Toplevel.setStartupId(java.lang.String)
is sufficient