Gdk.Device¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r |
Associated pointer or keyboard with this device |
||
r |
Axes |
||
r/w/co |
Device manager which the device belongs to |
||
r/w/co |
Display which the device belongs to |
||
r/w/co |
Whether there is a visible cursor following device motion |
||
r/w/en |
Input mode for the device |
||
r/w/co/en |
Source type for the device |
||
r |
Number of axes in the device |
||
r/w/co |
Device name |
||
r/w/co |
Number of concurrent touches |
||
r/w/co |
Product ID |
||
r/w |
Seat |
||
r |
The tool that is currently used with this device |
||
r/w/co |
Device role in the device manager |
||
r/w/co |
Vendor ID |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
The |
|
The |
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 informationdevice (
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
() wasTrue
.
- 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, or
None
- Return type:
Gdk.Device
orNone
Returns the associated device to self, if self is of type
Gdk.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.
- get_axes()[source]¶
- Return type:
Returns the axes currently available on the device.
New in version 3.22.
- get_axis_use(index_)[source]¶
- 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.
- get_device_type()[source]¶
- Returns:
the
Gdk.DeviceType
for self.- Return type:
Returns the device type for self.
New in version 3.0.
- get_display()[source]¶
- 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.
- get_has_cursor()[source]¶
-
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.
- get_key(index_)[source]¶
- 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
True
and 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
orNone
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.
- get_n_axes()[source]¶
- Returns:
the number of axes.
- Return type:
Returns the number of axes the device currently has.
New in version 3.0.
- get_n_keys()[source]¶
- Returns:
the number of keys.
- Return type:
Returns the number of keys the device currently has.
New in version 2.24.
- get_name()[source]¶
- Returns:
a name
- Return type:
Determines the name of the device.
New in version 2.20.
- get_position()[source]¶
- Returns:
- screen:
location to store the
Gdk.Screen
the self is on, orNone
.- 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, seeGdk.Device.grab
().New in version 3.0.
- get_position_double()[source]¶
- Returns:
- screen:
location to store the
Gdk.Screen
the self is on, orNone
.- 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. SeeGdk.Device.grab
().New in version 3.10.
- get_product_id()[source]¶
-
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. SeeGdk.Device.get_vendor_id
() for more information.New in version 3.16.
- get_vendor_id()[source]¶
-
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. composeGio.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, orNone
.- Return type:
(
Gdk.Window
orNone
, win_x:int
, win_y:int
)
Obtains the window underneath self, returning the location of the device in win_x and win_y. 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, seeGdk.Device.grab
().New in version 3.0.
- get_window_at_position_double()[source]¶
- Returns:
the
Gdk.Window
under the device position, orNone
.- Return type:
(
Gdk.Window
orNone
, 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, seeGdk.Device.grab
().New in version 3.0.
- grab(window, grab_ownership, owner_events, event_mask, cursor, time_)[source]¶
- Parameters:
window (
Gdk.Window
) – theGdk.Window
which will own the grab (the grab window)grab_ownership (
Gdk.GrabOwnership
) – specifies the grab ownership.owner_events (
bool
) – ifFalse
then all device events are reported with respect to window 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 by event_mask. In either mode, unreported events are discarded.event_mask (
Gdk.EventMask
) – specifies the event mask, which is used in accordance with owner_events.cursor (
Gdk.Cursor
orNone
) – the cursor to display while the grab is active if the device is a pointer. If this isNone
then the normal cursors are used for window 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 theGdk.Event
struct, thoughGdk.CURRENT_TIME
can 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 to
True
.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.EventGrabBroken
events that are emitted when the grab ends unvoluntarily.New in version 3.0.
Deprecated since version 3.20.: Use
Gdk.Seat.grab
() instead.
- list_axes()[source]¶
-
Returns a
GLib.List
ofGdk.Atoms
, containing the labels for the axes that self currently has.New in version 3.0.
- list_slave_devices()[source]¶
- 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
] orNone
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 axisuse (
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 setkeyval (
int
) – the keyval to generatemodifiers (
Gdk.ModifierType
) – the modifiers to set
Specifies the X key event to generate when a macro button of a device is pressed.
- set_mode(mode)[source]¶
- 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.
- ungrab(time_)[source]¶
- 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.
- warp(screen, x, y)[source]¶
- 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 theGdk.Device
has 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 signaltool (
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.MASTER
always come in keyboard/pointer pairs. Other device types will have aNone
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:
The
Gdk.DeviceManager
theGdk.Device
pertains to.New in version 3.0.
- Gdk.Device.props.display¶
- Name:
display
- Type:
- Default Value:
- Flags:
The
Gdk.Display
theGdk.Device
pertains to.New in version 3.0.
- Gdk.Device.props.has_cursor¶
- Name:
has-cursor
- Type:
- Default Value:
- Flags:
Whether the device is represented by a cursor on the screen. Devices of type
Gdk.DeviceType.MASTER
will haveTrue
here.New in version 3.0.
- Gdk.Device.props.input_mode¶
- Name:
input-mode
- Type:
- Default Value:
- Flags:
Input mode for the device
- Gdk.Device.props.input_source¶
- Name:
input-source
- Type:
- Default Value:
- Flags:
Source type for the device.
New in version 3.0.
- Gdk.Device.props.n_axes¶
-
Number of axes in the device.
New in version 3.0.
- Gdk.Device.props.name¶
- Name:
name
- Type:
- Default Value:
- Flags:
The device name.
New in version 3.0.
- Gdk.Device.props.num_touches¶
- Name:
num-touches
- Type:
- Default Value:
0
- Flags:
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:
Product ID of this device, see
Gdk.Device.get_product_id
().New in version 3.16.
- 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:
Device role in the device manager.
New in version 3.0.
- Gdk.Device.props.vendor_id¶
- Name:
vendor-id
- Type:
- Default Value:
- Flags:
Vendor ID of this device, see
Gdk.Device.get_vendor_id
().New in version 3.16.