Module: cwc.pointer

Low-level API to manage pointer and pointer device

Info:

  • Copyright: 2024
  • License: GPLv3
  • Originally authored by: Dwi Asmoro Bangun
    (Full contributors list available on our github project)

Fields

cwc.pointer.cursor_size integer Set cursor size.
cwc.pointer.inactive_timeout integer Set a timeout in seconds to automatically hide cursor, set timeout to 0 to disable.
cwc.pointer.edge_threshold integer Set a threshold distance for applying common tile position in pixel unit.

Static module functions

cwc.pointer.get () -> cwc_pointer[] Get all pointer in the server.
cwc.pointer.bind (modifier, mouse_btn, on_press, on_release, data) Register a mouse binding.
cwc.pointer.clear () Clear all mouse binding.
cwc.pointer.get_position () -> table Get main seat pointer position.
cwc.pointer.set_position (x, y) Set main seat pointer position.
cwc.pointer.move_interactive () Start interactive move for client under the cursor.
cwc.pointer.resize_interactive () Start interactive resize for client under the cursor.
cwc.pointer.stop_interactive () Stop interactive mode.

Config functions

cwc.pointer.set_edge_snapping_overlay_color (red, green, blue, alpha) Set color of the overlay when performing edge snapping.

Object properties

data table user data table Read only
seat string The seat names which the keyboard belong. Read only
position table The seat names which the keyboard belong. Read only
grab boolean Grab the mouse event and redirect it to signal. Read only
send_events boolean Send pointer events to the client. Read only

Object methods

:move (x, y, skip_events) Move pointer relative the current position.
:move_to (x, y, skip_events) Move pointer to the specified coordinate.

Signals

pointer::move Emitted when a pointer is moved or input device motion event is triggered.
pointer::button Emitted when a mouse button is pressed/released.
pointer::axis Emitted when an axis event is triggered.


Fields

🔗 cwc.pointer.cursor_size integer
Set cursor size.
🔗 cwc.pointer.inactive_timeout integer
Set a timeout in seconds to automatically hide cursor, set timeout to 0 to disable.
🔗 cwc.pointer.edge_threshold integer
Set a threshold distance for applying common tile position in pixel unit.

Static module functions

🔗 cwc.pointer.get () -> cwc_pointer[]
Get all pointer in the server.

Returns:

    cwc_pointer[]
🔗 cwc.pointer.bind (modifier, mouse_btn, on_press, on_release, data)
Register a mouse binding.

Parameters:

Name Type(s) Description
modifier table or number Table of modifier or modifier bitfield
mouse_btn number Button from linux input-event-codes
on_press func Function to execute when pressed
on_release Optional func Function to execute when released
data Optional table Additional data
group Optional string Keybinding group
description Optional string Keybinding description

See also:

cuteful.enum.modifier Keyboard modifier constant mapped from wlr_keyboard.h (cuteful.enum) tables
cuteful.enum.mouse_btn Extracted from Linux input-event-codes.h (cuteful.enum) tables
cwc.kbd.bind Register a keyboard binding to the default map. (cwc.kbd) static module functions
🔗 cwc.pointer.clear ()
Clear all mouse binding.
🔗 cwc.pointer.get_position () -> table
Get main seat pointer position.

Returns:

    table Pointer coords with structure {x,y}
🔗 cwc.pointer.set_position (x, y)
Set main seat pointer position.

Parameters:

Name Type(s) Description
x integer
y integer
🔗 cwc.pointer.move_interactive ()
Start interactive move for client under the cursor.
🔗 cwc.pointer.resize_interactive ()
Start interactive resize for client under the cursor.
🔗 cwc.pointer.stop_interactive ()
Stop interactive mode.

Config functions

🔗 cwc.pointer.set_edge_snapping_overlay_color (red, green, blue, alpha)
Set color of the overlay when performing edge snapping.

gears.color is not gonna work because the overlay isn't a cairo surface.

Parameters:

Name Type(s) Description
red number Value of red.
green number Value of green.
blue number Value of blue.
alpha number Alpha value.

Object properties

🔗 seat string · read only
The seat names which the keyboard belong.

Constraints:

Default value : "seat0"
🔗 position table · read only
The seat names which the keyboard belong.

Constraints:

Table keys:
x (table) : The x coordinate of the pointer
y (table) : The y coordinate of the pointer
🔗 grab boolean · read only
Grab the mouse event and redirect it to signal.

Constraints:

Default value : false
Valid values : true or false.
🔗 send_events boolean · read only
Send pointer events to the client.

Constraints:

Default value : true
Valid values : true or false.

Object methods

🔗 :move (x, y, skip_events)
Move pointer relative the current position.

Parameters:

Name Type(s) Description Default value
x integer The x vector. Not applicable
y integer The y vector. Not applicable
skip_events Optional boolean The motion won't be sent to client. false
🔗 :move_to (x, y, skip_events)
Move pointer to the specified coordinate.

Parameters:

Name Type(s) Description Default value
x integer The new x position. Not applicable
y integer The new y position. Not applicable
skip_events Optional boolean The motion won't be sent to client. false

Signals

🔗 pointer::move
Emitted when a pointer is moved or input device motion event is triggered.

Arguments:

Name Type(s) Description
pointer cwc_pointer The pointer object.
time_msec integer The event time in milliseconds.
dx number The x vector.
dy number The y vectork.
dx_unaccel number The x vector unaccelerated.
dy_unaccel number The y vector unaccelerated.
🔗 pointer::button
Emitted when a mouse button is pressed/released.

Arguments:

Name Type(s) Description
pointer cwc_pointer The pointer object.
time_msec integer The event time in milliseconds.
button integer The button code from linux/input-event-codes.h.
pressed boolean The state of the button, true means pressed.

See also:

cuteful.enum.mouse_btn Extracted from Linux input-event-codes.h (cuteful.enum) tables
🔗 pointer::axis
Emitted when an axis event is triggered.

Arguments:

Name Type(s) Description
pointer cwc_pointer The pointer object.
time_msec integer The event time in milliseconds.
horizontal boolean The orientation of the axis.
delta number
delta_discrete number
generated by LDoc 1.5.0 based on AwesomeWM template