Trait gdk4::prelude::DeviceExt

source ·
pub trait DeviceExt: IsA<Device> + Sealed + 'static {
Show 30 methods // Provided methods fn is_caps_locked(&self) -> bool { ... } fn device_tool(&self) -> Option<DeviceTool> { ... } fn direction(&self) -> Direction { ... } fn display(&self) -> Display { ... } fn has_cursor(&self) -> bool { ... } fn modifier_state(&self) -> ModifierType { ... } fn name(&self) -> GString { ... } fn is_num_locked(&self) -> bool { ... } fn num_touches(&self) -> u32 { ... } fn product_id(&self) -> Option<GString> { ... } fn is_scroll_locked(&self) -> bool { ... } fn seat(&self) -> Seat { ... } fn source(&self) -> InputSource { ... } fn surface_at_position(&self) -> (Option<Surface>, f64, f64) { ... } fn timestamp(&self) -> u32 { ... } fn vendor_id(&self) -> Option<GString> { ... } fn has_bidi_layouts(&self) -> bool { ... } fn n_axes(&self) -> u32 { ... } fn set_seat<P: IsA<Seat>>(&self, seat: Option<&P>) { ... } fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... } fn connect_tool_changed<F: Fn(&Self, &DeviceTool) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_caps_lock_state_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_direction_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_has_bidi_layouts_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_modifier_state_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_n_axes_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_num_lock_state_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_scroll_lock_state_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_seat_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... } fn connect_tool_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all Device methods.

§Implementors

DevicePad, Device

Provided Methods§

source

fn is_caps_locked(&self) -> bool

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 @self

source

fn device_tool(&self) -> Option<DeviceTool>

Retrieves the current tool for @self.

§Returns

the DeviceTool

source

fn direction(&self) -> Direction

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 unichar_direction().

§Returns

pango::Direction::Ltr or pango::Direction::Rtl if it can determine the direction. pango::Direction::Neutral otherwise

source

fn display(&self) -> Display

Returns the Display to which @self pertains.

§Returns

a Display

source

fn has_cursor(&self) -> bool

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

source

fn modifier_state(&self) -> ModifierType

Retrieves the current modifier state of the keyboard.

This is only relevant for keyboard devices.

§Returns

the current modifier state

source

fn name(&self) -> GString

The name of the device, suitable for showing in a user interface.

§Returns

a name

source

fn is_num_locked(&self) -> bool

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 @self

source

fn num_touches(&self) -> u32

Retrieves the number of touch points associated to @self.

§Returns

the number of touch points

source

fn product_id(&self) -> Option<GString>

Returns the product ID of this device.

This ID is retrieved from the device, and does not change. See vendor_id() for more information.

§Returns

the product ID

source

fn is_scroll_locked(&self) -> bool

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 @self

source

fn seat(&self) -> Seat

Returns the Seat the device belongs to.

§Returns

a Seat

source

fn source(&self) -> InputSource

Determines the type of the device.

§Returns

a InputSource

source

fn surface_at_position(&self) -> (Option<Surface>, f64, f64)

Obtains the surface underneath @self, returning the location of the device in @win_x and @win_y.

Returns None if the surface tree under @self is not known to GDK (for example, belongs to another application).

§Returns

the Surface under the device position

§win_x

return location for the X coordinate of the device location relative to the surface origin

§win_y

return location for the Y coordinate of the device location relative to the surface origin

source

fn timestamp(&self) -> u32

Available on crate feature v4_2 only.

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

source

fn vendor_id(&self) -> Option<GString>

Returns the vendor ID of this device.

This ID is retrieved from the device, and does not change.

This function, together with product_id(), can be used to eg. compose GSettings paths to store settings for this device.

⚠️ The following code is in c ⚠️

 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

source

fn has_bidi_layouts(&self) -> bool

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

source

fn n_axes(&self) -> u32

Number of axes in the device.

source

fn set_seat<P: IsA<Seat>>(&self, seat: Option<&P>)

Seat of this device.

source

fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

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.

source

fn connect_tool_changed<F: Fn(&Self, &DeviceTool) + 'static>( &self, f: F ) -> SignalHandlerId

Emitted on pen/eraser devices whenever tools enter or leave proximity.

§tool

The new current tool

source

fn connect_caps_lock_state_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_direction_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_has_bidi_layouts_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_modifier_state_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_n_axes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

source

fn connect_num_lock_state_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_scroll_lock_state_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

fn connect_seat_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

source

fn connect_tool_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<O: IsA<Device>> DeviceExt for O