Class Device
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Device.Device$Impl,DevicePad.DevicePad$Impl
See the Seat documentation for more information
about the various kinds of devices, and their relationships.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDevice.Builder<B extends Device.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theChangedCallbackcallback.static classThe Device$Impl type represents a native instance of the abstract Device class.static interfaceFunctional interface declaration of theToolChangedCallbackcallback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionDevice()Creates a new Device.Device(MemorySegment address) Create a Device proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected DeviceasParent()Returns this instance as if it were its parent type.voidEmits the "changed" signal.voidemitToolChanged(@Nullable DeviceTool tool) Emits the "tool-changed" signal.intRetrieves the index of the active layout of the keyboard.booleanRetrieves whether the Caps Lock modifier of the keyboard is locked.@Nullable DeviceToolRetrieves the current tool fordevice.Returns the direction of effective layout of the keyboard.Returns theGdkDisplayto which this Device pertains.booleanDetermines whether the pointer follows device motion.@Nullable String @Nullable []Retrieves the names of the layouts of the keyboard.Retrieves the current modifier state of the keyboard.getName()The name of the device, suitable for showing in a user interface.booleanRetrieves whether the Num Lock modifier of the keyboard is locked.intRetrieves the number of touch points associated todevice.@Nullable StringReturns the product ID of this device.booleanRetrieves whether the Scroll Lock modifier of the keyboard is locked.getSeat()Returns theGdkSeatthe device belongs to.Determines the type of the device.@Nullable SurfacegetSurfaceAtPosition(@Nullable Out<Double> winX, @Nullable Out<Double> winY) Obtains the surface underneathdevice,returning the location of the device inwinXandwinY.intReturns the timestamp of the last activity for this device.static @Nullable TypegetType()Get the GType of the Device class@Nullable StringReturns the vendor ID of this device.booleanDetermines 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, builder, 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
-
Device
Create a Device proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Device
public Device()Creates a new Device.
-
-
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. -
getActiveLayoutIndex
public int getActiveLayoutIndex()Retrieves the index of the active layout of the keyboard.If there is no valid active layout for the
GdkDevice, this function will return -1;This is only relevant for keyboard devices.
- Returns:
- The layout index of the active layout or -1.
- Since:
- 4.18
-
getCapsLockState
public boolean getCapsLockState()Retrieves whether the Caps Lock modifier of the keyboard is locked.This is only relevant for keyboard devices.
- Returns:
trueif Caps Lock is on for this Device
-
getDeviceTool
Retrieves the current tool fordevice.- 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.LTRorDirection.RTLif it can determine the direction.Direction.NEUTRALotherwise
-
getDisplay
Returns theGdkDisplayto 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:
trueif the pointer follows device motion
-
getLayoutNames
Retrieves the names of the layouts of the keyboard.This is only relevant for keyboard devices.
- Returns:
null-terminated array of strings of layouts,- Since:
- 4.18
-
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:
trueif Num Lock is on for this Device
-
getNumTouches
public int getNumTouches()Retrieves the number of touch points associated todevice.- 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:
trueif Scroll Lock is on for this Device
-
getSeat
-
getSource
-
getSurfaceAtPosition
public @Nullable Surface getSurfaceAtPosition(@Nullable Out<Double> winX, @Nullable Out<Double> winY) Obtains the surface underneathdevice,returning the location of the device inwinXandwinY.Returns
nullif 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
GdkSurfaceunder 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
- Since:
- 4.2
-
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. composeGSettingspaths 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:
trueif there are layouts with both directions,falseotherwise
-
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).
-