Gdk.Device - Classes - Gdk 3.0 (original) (raw)
g GObject.Object GObject.Object Gdk.Device Gdk.Device GObject.Object->Gdk.Device
Subclasses:
None
Methods¶
Inherited:
Structs:
class | grab_info_libgtk_only (display, device) |
---|---|
get_associated_device () | |
get_axes () | |
get_axis_use (index_) | |
get_device_type () | |
get_display () | |
get_has_cursor () | |
get_key (index_) | |
get_last_event_window () | |
get_mode () | |
get_n_axes () | |
get_n_keys () | |
get_name () | |
get_position () | |
get_position_double () | |
get_product_id () | |
get_seat () | |
get_source () | |
get_vendor_id () | |
get_window_at_position () | |
get_window_at_position_double () | |
grab (window, grab_ownership, owner_events, event_mask, cursor, time_) | |
list_axes () | |
list_slave_devices () | |
set_axis_use (index_, use) | |
set_key (index_, keyval, modifiers) | |
set_mode (mode) | |
ungrab (time_) | |
warp (screen, x, y) |
Virtual Methods¶
Inherited:
Properties¶
Name | Type | Flags | Short Description |
---|---|---|---|
associated-device | Gdk.Device | r | Associated pointer or keyboard with this device |
axes | Gdk.AxisFlags | r | Axes |
device-manager | Gdk.DeviceManager | r/w/co | Device manager which the device belongs to |
display | Gdk.Display | r/w/co | Display which the device belongs to |
has-cursor | bool | r/w/co | Whether there is a visible cursor following device motion |
input-mode | Gdk.InputMode | r/w/en | Input mode for the device |
input-source | Gdk.InputSource | r/w/co/en | Source type for the device |
n-axes | int | r | Number of axes in the device |
name | str | r/w/co | Device name |
num-touches | int | r/w/co | Number of concurrent touches |
product-id | str | r/w/co | Product ID |
seat | Gdk.Seat | r/w | Seat |
tool | Gdk.DeviceTool | r | The tool that is currently used with this device |
type | Gdk.DeviceType | r/w/co | Device role in the device manager |
vendor-id | str | r/w/co | Vendor ID |
Signals¶
Inherited:
Name | Short Description |
---|---|
changed | The ::changed signal is emitted either when the Gdk.Device has changed the number of either axes or keys. |
tool-changed | The ::tool-changed signal is emitted on pen/eraser Gdk.Devices whenever tools enter or leave proximity. |
Fields¶
Inherited:
Class Details¶
class Gdk.Device(**kwargs)¶
Bases:
Abstract:
Yes
The Gdk.Device object represents a single input device, such as a keyboard, a mouse, a touchpad, etc.
See the Gdk.DeviceManager documentation for more information about the various kinds of master and slave devices, and their relationships.
classmethod grab_info_libgtk_only(display, device)[source]¶
Parameters:
- display (Gdk.Display) – the display for which to get the grab information
- device (Gdk.Device) – device to get the grab information from
Returns:
True if this application currently has the keyboard grabbed.
grab_window:
location to store current grab window
owner_events:
location to store boolean indicating whether the owner_events flag to Gdk.keyboard_grab() orGdk.pointer_grab() was True.
Return type:
(bool, grab_window: Gdk.Window, owner_events: bool)
Determines information about the current keyboard grab. This is not public API and must not be used by applications.
Deprecated since version 3.16: The symbol was never meant to be used outside of GTK+
get_associated_device()[source]¶
Returns:
The associated device, orNone
Return type:
Gdk.Device or None
Returns the associated device to self, if self is of typeGdk.DeviceType.MASTER, it will return the paired pointer or keyboard.
If self is of type Gdk.DeviceType.SLAVE, it will return the master device to which self is attached to.
If self is of type Gdk.DeviceType.FLOATING, None will be returned, as there is no associated device.
New in version 3.0.
Return type:
Returns the axes currently available on the device.
New in version 3.22.
Parameters:
index (int) – the index of the axis.
Returns:
a Gdk.AxisUse specifying how the axis is used.
Return type:
Returns the axis use for index_.
New in version 2.20.
Returns:
the Gdk.DeviceType for self.
Return type:
Returns the device type for self.
New in version 3.0.
Returns:
a Gdk.Display. This memory is owned by GTK+, and must not be freed or unreffed.
Return type:
Returns the Gdk.Display to which self pertains.
New in version 3.0.
Returns:
True if the pointer follows device motion
Return type:
Determines whether the pointer follows device motion. This is not meaningful for keyboard devices, which don’t have a pointer.
New in version 2.20.
Parameters:
index (int) – the index of the macro button to get.
Returns:
True if keyval is set for index.
keyval:
return value for the keyval.
modifiers:
return value for modifiers.
Return type:
(bool, keyval: int, modifiers: Gdk.ModifierType)
If index_ has a valid keyval, this function will return Trueand fill in keyval and modifiers with the keyval settings.
New in version 2.20.
get_last_event_window()[source]¶
Returns:
the last window the device
Return type:
Gdk.Window or None
Gets information about which window the given pointer device is in, based on events that have been received so far from the display server. If another application has a pointer grab, or this application has a grab with owner_events = False,None may be returned even if the pointer is physically over one of this application’s windows.
New in version 3.12.
Returns:
Return type:
Determines the mode of the device.
New in version 2.20.
Returns:
the number of axes.
Return type:
Returns the number of axes the device currently has.
New in version 3.0.
Returns:
the number of keys.
Return type:
Returns the number of keys the device currently has.
New in version 2.24.
Returns:
a name
Return type:
Determines the name of the device.
New in version 2.20.
Returns:
screen:
location to store the Gdk.Screenthe self is on, or None.
x:
location to store root window X coordinate of self, or None.
y:
location to store root window Y coordinate of self, or None.
Return type:
(screen: Gdk.Screen, x: int, y: int)
Gets the current location of self. As a slave device coordinates are those of its master pointer, This function may not be called on devices of type Gdk.DeviceType.SLAVE, unless there is an ongoing grab on them, see Gdk.Device.grab().
New in version 3.0.
get_position_double()[source]¶
Returns:
screen:
location to store the Gdk.Screenthe self is on, or None.
x:
location to store root window X coordinate of self, or None.
y:
location to store root window Y coordinate of self, or None.
Return type:
(screen: Gdk.Screen, x: float, y: float)
Gets the current location of self in double precision. As a slave device’s coordinates are those of its master pointer, this function may not be called on devices of type Gdk.DeviceType.SLAVE, unless there is an ongoing grab on them. See Gdk.Device.grab().
New in version 3.10.
Returns:
the product ID, or None
Return type:
Returns the product ID of this device, or None if this information couldn’t be obtained. This ID is retrieved from the device, and is thus constant for it. See Gdk.Device.get_vendor_id() for more information.
New in version 3.16.
Returns:
A Gdk.Seat. This memory is owned by GTK+ and must not be freed.
Return type:
Returns the Gdk.Seat the device belongs to.
New in version 3.20.
Returns:
Return type:
Determines the type of the device.
New in version 2.20.
Returns:
the vendor ID, or None
Return type:
Returns the vendor ID of this device, or None if this information couldn’t be obtained. This ID is retrieved from the device, and is thus constant for it.
This function, together with Gdk.Device.get_product_id(), can be used to eg. compose Gio.Settings paths to store settings for this device.
static GSettings * get_device_settings (GdkDevice *device) { const gchar *vendor, *product; GSettings *settings; GdkDevice *device; gchar *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; }
New in version 3.16.
get_window_at_position()[source]¶
Returns:
the Gdk.Window under the device position, or None.
win_x:
return location for the X coordinate of the device location, relative to the window origin, or None.
win_y:
return location for the Y coordinate of the device location, relative to the window origin, or None.
Return type:
(Gdk.Window or None, win_x: int, win_y: int)
Obtains the window underneath self, returning the location of the device in win_x and win_y. ReturnsNone if the window tree under self is not known to GDK (for example, belongs to another application).
As a slave device coordinates are those of its master pointer, This function may not be called on devices of type Gdk.DeviceType.SLAVE, unless there is an ongoing grab on them, see Gdk.Device.grab().
New in version 3.0.
get_window_at_position_double()[source]¶
Returns:
the Gdk.Window under the device position, or None.
win_x:
return location for the X coordinate of the device location, relative to the window origin, or None.
win_y:
return location for the Y coordinate of the device location, relative to the window origin, or None.
Return type:
(Gdk.Window or None, win_x: float, win_y: float)
Obtains the window underneath self, returning the location of the device in win_x and win_y in double precision. Returns None if the window tree under self is not known to GDK (for example, belongs to another application).
As a slave device coordinates are those of its master pointer, This function may not be called on devices of type Gdk.DeviceType.SLAVE, unless there is an ongoing grab on them, see Gdk.Device.grab().
New in version 3.0.
grab(window, grab_ownership, owner_events, event_mask, cursor, time_)[source]¶
Parameters:
- window (Gdk.Window) – the Gdk.Window which will own the grab (the grab window)
- grab_ownership (Gdk.GrabOwnership) – specifies the grab ownership.
- owner_events (bool) – if False then all device events are reported with respect towindow and are only reported if selected by event_mask. IfTrue then pointer events for this application are reported as normal, but pointer events outside this application are reported with respect to window and only if selected byevent_mask. In either mode, unreported events are discarded.
- event_mask (Gdk.EventMask) – specifies the event mask, which is used in accordance withowner_events.
- cursor (Gdk.Cursor or None) – the cursor to display while the grab is active if the device is a pointer. If this is None then the normal cursors are used forwindow and its descendants, and the cursor for window is used elsewhere.
- time (int) – the timestamp of the event which led to this pointer grab. This usually comes from the Gdk.Event struct, though Gdk.CURRENT_TIMEcan be used if the time isn’t known.
Returns:
Gdk.GrabStatus.SUCCESS if the grab was successful.
Return type:
Grabs the device so that all events coming from this device are passed to this application until the device is ungrabbed with Gdk.Device.ungrab(), or the window becomes unviewable. This overrides any previous grab on the device by this client.
Note that self and window need to be on the same display.
Device grabs are used for operations which need complete control over the given device events (either pointer or keyboard). For example in GTK+ this is used for Drag and Drop operations, popup menus and such.
Note that if the event mask of an X window has selected both button press and button release events, then a button press event will cause an automatic pointer grab until the button is released. X does this automatically since most applications expect to receive button press and release events in pairs. It is equivalent to a pointer grab on the window with owner_events set toTrue.
If you set up anything at the time you take the grab that needs to be cleaned up when the grab ends, you should handle the Gdk.EventGrabBrokenevents that are emitted when the grab ends unvoluntarily.
New in version 3.0.
Deprecated since version 3.20.: Use Gdk.Seat.grab() instead.
Returns:
A GLib.List of Gdk.Atoms, free with g_list_free().
Return type:
[Gdk.Atom]
Returns a GLib.List of Gdk.Atoms, containing the labels for the axes that self currently has.
New in version 3.0.
Returns:
the list of slave devices, or None. The list must be freed with g_list_free(), the contents of the list are owned by GTK+ and should not be freed.
Return type:
[Gdk.Device] or None
If the device if of type Gdk.DeviceType.MASTER, it will return the list of slave devices attached to it, otherwise it will returnNone
set_axis_use(index_, use)[source]¶
Parameters:
- index (int) – the index of the axis
- use (Gdk.AxisUse) – specifies how the axis is used
Specifies how an axis of a device is used.
set_key(index_, keyval, modifiers)[source]¶
Parameters:
- index (int) – the index of the macro button to set
- keyval (int) – the keyval to generate
- modifiers (Gdk.ModifierType) – the modifiers to set
Specifies the X key event to generate when a macro button of a device is pressed.
Parameters:
mode (Gdk.InputMode) – the input mode.
Returns:
True if the mode was successfully changed.
Return type:
Sets a the mode of an input device. The mode controls if the device is active and whether the device’s range is mapped to the entire screen or to a single window.
Note: This is only meaningful for floating devices, master devices (and slaves connected to these) drive the pointer cursor, which is not limited by the input mode.
Parameters:
time (int) – a timestap (e.g. Gdk.CURRENT_TIME).
Release any grab on self.
New in version 3.0.
Deprecated since version 3.20.: Use Gdk.Seat.ungrab() instead.
Parameters:
- screen (Gdk.Screen) – the screen to warp self to.
- x (int) – the X coordinate of the destination.
- y (int) – the Y coordinate of the destination.
Warps self in display to the point x,`y` on the screen screen, unless the device is confined to a window by a grab, in which case it will be moved as far as allowed by the grab. Warping the pointer creates events as if the user had moved the mouse instantaneously to the destination.
Note that the pointer should normally be under the control of the user. This function was added to cover some rare use cases like keyboard navigation support for the color picker in the #GtkColorSelectionDialog.
New in version 3.0.
Signal Details¶
Gdk.Device.signals.changed(device)¶
Signal Name:
changed
Flags:
Parameters:
device (Gdk.Device) – The object which received the signal
The ::changed signal is emitted either when the Gdk.Devicehas changed the number of either axes or keys. For example In X this will normally happen when the slave device routing events through the master device changes (for example, user switches from the USB mouse to a tablet), in that case the master device will change to reflect the new slave device axes and keys.
Gdk.Device.signals.tool_changed(device, tool)¶
Signal Name:
tool-changed
Flags:
Parameters:
- device (Gdk.Device) – The object which received the signal
- tool (Gdk.DeviceTool) – The new current tool
The ::tool-changed signal is emitted on pen/eraserGdk.Devices whenever tools enter or leave proximity.
New in version 3.22.
Property Details¶
Gdk.Device.props.associated_device¶
Name:
associated-device
Type:
Default Value:
Flags:
Associated pointer or keyboard with this device, if any. Devices of type Gdk.DeviceType.MASTERalways come in keyboard/pointer pairs. Other device types will have a None associated device.
New in version 3.0.
Gdk.Device.props.axes¶
Name:
axes
Type:
Default Value:
0
Flags:
The axes currently available for this device.
New in version 3.22.
Gdk.Device.props.device_manager¶
Name:
device-manager
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY
The Gdk.DeviceManager the Gdk.Device pertains to.
New in version 3.0.
Gdk.Device.props.display¶
Name:
display
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY
The Gdk.Display the Gdk.Device pertains to.
New in version 3.0.
Gdk.Device.props.has_cursor¶
Name:
has-cursor
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY
Whether the device is represented by a cursor on the screen. Devices of typeGdk.DeviceType.MASTER will have True here.
New in version 3.0.
Gdk.Device.props.input_mode¶
Name:
input-mode
Type:
Default Value:
Flags:
READABLE, WRITABLE, EXPLICIT_NOTIFY
Input mode for the device
Gdk.Device.props.input_source¶
Name:
input-source
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY
Source type for the device.
New in version 3.0.
Gdk.Device.props.n_axes¶
Name:
n-axes
Type:
Default Value:
0
Flags:
Number of axes in the device.
New in version 3.0.
Gdk.Device.props.name¶
Name:
name
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY
The device name.
New in version 3.0.
Gdk.Device.props.num_touches¶
Name:
num-touches
Type:
Default Value:
0
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY
The maximal number of concurrent touches on a touch device. Will be 0 if the device is not a touch device or if the number of touches is unknown.
New in version 3.20.
Gdk.Device.props.product_id¶
Name:
product-id
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY
Product ID of this device, see Gdk.Device.get_product_id().
New in version 3.16.
Gdk.Device.props.seat¶
Name:
seat
Type:
Default Value:
Flags:
Gdk.Seat of this device.
New in version 3.20.
Gdk.Device.props.tool¶
Name:
tool
Type:
Default Value:
Flags:
The tool that is currently used with this device
Gdk.Device.props.type¶
Name:
type
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY
Device role in the device manager.
New in version 3.0.
Gdk.Device.props.vendor_id¶
Name:
vendor-id
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY
Vendor ID of this device, see Gdk.Device.get_vendor_id().
New in version 3.16.