Class Device
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Device.DeviceImpl
,DevicePad.DevicePadImpl
GdkDevice
object represents an input device, such
as a keyboard, a mouse, or a touchpad.
See the Seat
documentation for more information
about the various kinds of devices, and their relationships.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Device.Builder<B extends Device.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theChangedCallback
callback.static class
The DeviceImpl type represents a native instance of the abstract Device class.static interface
Functional interface declaration of theToolChangedCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionDevice
(MemorySegment address) Create a Device proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected Device
asParent()
Returns this instance as if it were its parent type.static Device.Builder
<? extends Device.Builder> builder()
ADevice.Builder
object constructs aDevice
with the specified properties.void
Emits the "changed" signal.void
emitToolChanged
(DeviceTool tool) Emits the "tool-changed" signal.boolean
Retrieves whether the Caps Lock modifier of the keyboard is locked.Retrieves the current tool for this Device.Returns the direction of effective layout of the keyboard.Returns theGdkDisplay
to which this Device pertains.boolean
Determines whether the pointer follows device motion.Retrieves the current modifier state of the keyboard.getName()
The name of the device, suitable for showing in a user interface.boolean
Retrieves whether the Num Lock modifier of the keyboard is locked.int
Retrieves the number of touch points associated to this Device.Returns the product ID of this device.boolean
Retrieves whether the Scroll Lock modifier of the keyboard is locked.getSeat()
Returns theGdkSeat
the device belongs to.Determines the type of the device.getSurfaceAtPosition
(@Nullable Out<Double> winX, @Nullable Out<Double> winY) Obtains the surface underneath this Device, returning the location of the device inwinX
andwinY
.int
Returns the timestamp of the last activity for this device.static Type
getType()
Get the GType of the Device classReturns the vendor ID of this device.boolean
Determines if layouts for both right-to-left and left-to-right languages are in use on the keyboard.onChanged
(Device.ChangedCallback handler) Emitted either when the number of either axes or keys changes.onToolChanged
(Device.ToolChangedCallback handler) Emitted on pen/eraser devices whenever tools enter or leave proximity.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
-
Device
Create a Device 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. -
getCapsLockState
public boolean getCapsLockState()Retrieves whether the Caps Lock modifier of the keyboard is locked.This is only relevant for keyboard devices.
- Returns:
true
if Caps Lock is on for this Device
-
getDeviceTool
Retrieves the current tool for this Device.- Returns:
- the
GdkDeviceTool
-
getDirection
Returns the direction of effective layout of the keyboard.This is only relevant for keyboard devices.
The direction of a layout is the direction of the majority of its symbols. See
Pango.unicharDirection(int)
.- Returns:
Direction.LTR
orDirection.RTL
if it can determine the direction.Direction.NEUTRAL
otherwise
-
getDisplay
Returns theGdkDisplay
to which this Device pertains.- Returns:
- a
GdkDisplay
-
getHasCursor
public boolean getHasCursor()Determines whether the pointer follows device motion.This is not meaningful for keyboard devices, which don't have a pointer.
- Returns:
true
if the pointer follows device motion
-
getModifierState
Retrieves the current modifier state of the keyboard.This is only relevant for keyboard devices.
- Returns:
- the current modifier state
-
getName
The name of the device, suitable for showing in a user interface.- Returns:
- a name
-
getNumLockState
public boolean getNumLockState()Retrieves whether the Num Lock modifier of the keyboard is locked.This is only relevant for keyboard devices.
- Returns:
true
if Num Lock is on for this Device
-
getNumTouches
public int getNumTouches()Retrieves the number of touch points associated to this Device.- Returns:
- the number of touch points
-
getProductId
Returns the product ID of this device.This ID is retrieved from the device, and does not change. See
getVendorId()
for more information.- Returns:
- the product ID
-
getScrollLockState
public boolean getScrollLockState()Retrieves whether the Scroll Lock modifier of the keyboard is locked.This is only relevant for keyboard devices.
- Returns:
true
if Scroll Lock is on for this Device
-
getSeat
-
getSource
-
getSurfaceAtPosition
public Surface getSurfaceAtPosition(@Nullable @Nullable Out<Double> winX, @Nullable @Nullable Out<Double> winY) Obtains the surface underneath this Device, returning the location of the device inwinX
andwinY
.Returns
null
if the surface tree under this Device is not known to GDK (for example, belongs to another application).- Parameters:
winX
- return location for the X coordinate of the device location relative to the surface originwinY
- return location for the Y coordinate of the device location relative to the surface origin- Returns:
- the
GdkSurface
under the device position
-
getTimestamp
public int getTimestamp()Returns the timestamp of the last activity for this device.In practice, this means the timestamp of the last event that was received from the OS for this device. (GTK may occasionally produce events for a device that are not received from the OS, and will not update the timestamp).
- Returns:
- the timestamp of the last activity for this device
-
getVendorId
Returns the vendor ID of this device.This ID is retrieved from the device, and does not change.
This function, together with
getProductId()
, can be used to eg. composeGSettings
paths to store settings for this device.static GSettings * get_device_settings (GdkDevice *device) { const char *vendor, *product; GSettings *settings; GdkDevice *device; char *path; vendor = gdk_device_get_vendor_id (device); product = gdk_device_get_product_id (device); path = g_strdup_printf ("/org/example/app/devices/%s:%s/", vendor, product); settings = g_settings_new_with_path (DEVICE_SCHEMA, path); g_free (path); return settings; }
- Returns:
- the vendor ID
-
hasBidiLayouts
public boolean hasBidiLayouts()Determines if layouts for both right-to-left and left-to-right languages are in use on the keyboard.This is only relevant for keyboard devices.
- Returns:
true
if there are layouts with both directions,false
otherwise
-
onChanged
Emitted either when the number of either axes or keys changes.On X11 this will normally happen when the physical device routing events through the logical device changes (for example, user switches from the USB mouse to a tablet); in that case the logical device will change to reflect the axes and keys on the new physical device.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitChanged
public void emitChanged()Emits the "changed" signal. SeeonChanged(org.gnome.gdk.Device.ChangedCallback)
. -
onToolChanged
public SignalConnection<Device.ToolChangedCallback> onToolChanged(Device.ToolChangedCallback handler) Emitted on pen/eraser devices whenever tools enter or leave proximity.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitToolChanged
Emits the "tool-changed" signal. SeeonToolChanged(org.gnome.gdk.Device.ToolChangedCallback)
. -
builder
ADevice.Builder
object constructs aDevice
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withDevice.Builder.build()
.
-