bd44b5aa08
Test / build-libghostty-vt (x86_64-windows-gnu) (push) Has been cancelled
Test / build-libghostty-vt-macos (aarch64-ios) (push) Has been cancelled
Test / build-libghostty-vt-macos (aarch64-macos) (push) Has been cancelled
Test / build-libghostty-vt-macos (x86_64-macos) (push) Has been cancelled
Test / build-nix (namespace-profile-ghostty-md-arm64) (push) Has been cancelled
Test / build-dist (push) Has been cancelled
Test / GTK x11=true wayland=true (push) Has been cancelled
Test / Build -Dsimd=false (push) Has been cancelled
Test / Build -Dsimd=true (push) Has been cancelled
Test / Build -Dsentry=false (push) Has been cancelled
Test / Build -Dsentry=true (push) Has been cancelled
Test / zig-fmt (push) Has been cancelled
Test / GitHub Actions Pins (push) Has been cancelled
Test / prettier (push) Has been cancelled
Test / swiftlint (push) Has been cancelled
Test / alejandra (push) Has been cancelled
Test / typos (push) Has been cancelled
Nix / Required Checks: Nix (push) Has been cancelled
Nix / check-zig-cache-hash (push) Has been cancelled
Test / skip (push) Has been cancelled
Test / Required Checks: Test (push) Has been cancelled
Test / build-bench (push) Has been cancelled
Test / list-examples (push) Has been cancelled
Test / Example ${{ matrix.dir }} (Windows) (push) Has been cancelled
Test / build-cmake (push) Has been cancelled
Test / test-lib-vt-pkgconfig (push) Has been cancelled
Test / build-flatpak (push) Has been cancelled
Test / build-snap (push) Has been cancelled
Test / build-libghostty-vt (aarch64-linux) (push) Has been cancelled
Test / build-libghostty-vt (aarch64-macos) (push) Has been cancelled
Test / build-libghostty-vt (wasm32-freestanding) (push) Has been cancelled
Test / build-libghostty-vt (x86_64-linux) (push) Has been cancelled
Test / build-libghostty-vt (x86_64-linux-musl) (push) Has been cancelled
Test / build-libghostty-vt (x86_64-macos) (push) Has been cancelled
Test / build-libghostty-vt-android (aarch64-linux-android) (push) Has been cancelled
Test / build-libghostty-vt-android (arm-linux-androideabi) (push) Has been cancelled
Test / build-libghostty-vt-android (x86_64-linux-android) (push) Has been cancelled
Test / build-libghostty-vt-windows (push) Has been cancelled
Test / build-libghostty-windows-gnu (push) Has been cancelled
Test / build-linux (namespace-profile-ghostty-md) (push) Has been cancelled
Test / build-linux (namespace-profile-ghostty-md-arm64) (push) Has been cancelled
Test / build-linux-libghostty (push) Has been cancelled
Test / build-nix (namespace-profile-ghostty-md) (push) Has been cancelled
Test / build-dist-lib-vt (push) Has been cancelled
Test / trigger-snap (push) Has been cancelled
Test / trigger-flatpak (push) Has been cancelled
Test / build-macos (push) Has been cancelled
Test / build-macos-freetype (push) Has been cancelled
Test / test (push) Has been cancelled
Test / test-lib-vt (push) Has been cancelled
Test / GTK x11=false wayland=false (push) Has been cancelled
Test / GTK x11=true wayland=false (push) Has been cancelled
Test / GTK x11=false wayland=true (push) Has been cancelled
Test / test-macos (push) Has been cancelled
Test / test-windows (push) Has been cancelled
Test / Build -Di18n=false (push) Has been cancelled
Test / Build -Di18n=true (push) Has been cancelled
Test / Build test/fuzz-libghostty (push) Has been cancelled
Test / shellcheck (push) Has been cancelled
Test / translations (push) Has been cancelled
Test / blueprint-compiler (push) Has been cancelled
Test / Test pkg/wuffs (push) Has been cancelled
Test / Test build on Debian 13 (push) Has been cancelled
Test / valgrind (push) Has been cancelled
Test / Example ${{ matrix.dir }} (push) Has been cancelled
196 lines
4.8 KiB
C
196 lines
4.8 KiB
C
/**
|
|
* @file event.h
|
|
*
|
|
* Mouse event representation and manipulation.
|
|
*/
|
|
|
|
#ifndef GHOSTTY_VT_MOUSE_EVENT_H
|
|
#define GHOSTTY_VT_MOUSE_EVENT_H
|
|
|
|
#include <stdbool.h>
|
|
#include <ghostty/vt/allocator.h>
|
|
#include <ghostty/vt/key/event.h>
|
|
#include <ghostty/vt/types.h>
|
|
|
|
/**
|
|
* Opaque handle to a mouse event.
|
|
*
|
|
* This handle represents a normalized mouse input event containing
|
|
* action, button, modifiers, and surface-space position.
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
typedef struct GhosttyMouseEventImpl *GhosttyMouseEvent;
|
|
|
|
/**
|
|
* Mouse event action type.
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
typedef enum GHOSTTY_ENUM_TYPED {
|
|
/** Mouse button was pressed. */
|
|
GHOSTTY_MOUSE_ACTION_PRESS = 0,
|
|
|
|
/** Mouse button was released. */
|
|
GHOSTTY_MOUSE_ACTION_RELEASE = 1,
|
|
|
|
/** Mouse moved. */
|
|
GHOSTTY_MOUSE_ACTION_MOTION = 2,
|
|
GHOSTTY_MOUSE_ACTION_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
|
|
} GhosttyMouseAction;
|
|
|
|
/**
|
|
* Mouse button identity.
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
typedef enum GHOSTTY_ENUM_TYPED {
|
|
GHOSTTY_MOUSE_BUTTON_UNKNOWN = 0,
|
|
GHOSTTY_MOUSE_BUTTON_LEFT = 1,
|
|
GHOSTTY_MOUSE_BUTTON_RIGHT = 2,
|
|
GHOSTTY_MOUSE_BUTTON_MIDDLE = 3,
|
|
GHOSTTY_MOUSE_BUTTON_FOUR = 4,
|
|
GHOSTTY_MOUSE_BUTTON_FIVE = 5,
|
|
GHOSTTY_MOUSE_BUTTON_SIX = 6,
|
|
GHOSTTY_MOUSE_BUTTON_SEVEN = 7,
|
|
GHOSTTY_MOUSE_BUTTON_EIGHT = 8,
|
|
GHOSTTY_MOUSE_BUTTON_NINE = 9,
|
|
GHOSTTY_MOUSE_BUTTON_TEN = 10,
|
|
GHOSTTY_MOUSE_BUTTON_ELEVEN = 11,
|
|
GHOSTTY_MOUSE_BUTTON_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
|
|
} GhosttyMouseButton;
|
|
|
|
/**
|
|
* Mouse position in surface-space pixels.
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
typedef struct {
|
|
float x;
|
|
float y;
|
|
} GhosttyMousePosition;
|
|
|
|
/**
|
|
* Create a new mouse event instance.
|
|
*
|
|
* @param allocator Pointer to allocator, or NULL to use the default allocator
|
|
* @param event Pointer to store the created event handle
|
|
* @return GHOSTTY_SUCCESS on success, or an error code on failure
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
GHOSTTY_API GhosttyResult ghostty_mouse_event_new(const GhosttyAllocator *allocator,
|
|
GhosttyMouseEvent *event);
|
|
|
|
/**
|
|
* Free a mouse event instance.
|
|
*
|
|
* @param event The mouse event handle to free (may be NULL)
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
GHOSTTY_API void ghostty_mouse_event_free(GhosttyMouseEvent event);
|
|
|
|
/**
|
|
* Set the event action.
|
|
*
|
|
* @param event The event handle, must not be NULL
|
|
* @param action The action to set
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
GHOSTTY_API void ghostty_mouse_event_set_action(GhosttyMouseEvent event,
|
|
GhosttyMouseAction action);
|
|
|
|
/**
|
|
* Get the event action.
|
|
*
|
|
* @param event The event handle, must not be NULL
|
|
* @return The event action
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
GHOSTTY_API GhosttyMouseAction ghostty_mouse_event_get_action(GhosttyMouseEvent event);
|
|
|
|
/**
|
|
* Set the event button.
|
|
*
|
|
* This sets a concrete button identity for the event.
|
|
* To represent "no button" (for motion events), use
|
|
* ghostty_mouse_event_clear_button().
|
|
*
|
|
* @param event The event handle, must not be NULL
|
|
* @param button The button to set
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
GHOSTTY_API void ghostty_mouse_event_set_button(GhosttyMouseEvent event,
|
|
GhosttyMouseButton button);
|
|
|
|
/**
|
|
* Clear the event button.
|
|
*
|
|
* This sets the event button to "none".
|
|
*
|
|
* @param event The event handle, must not be NULL
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
GHOSTTY_API void ghostty_mouse_event_clear_button(GhosttyMouseEvent event);
|
|
|
|
/**
|
|
* Get the event button.
|
|
*
|
|
* @param event The event handle, must not be NULL
|
|
* @param out_button Output pointer for the button value (may be NULL)
|
|
* @return true if a button is set, false if no button is set
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
GHOSTTY_API bool ghostty_mouse_event_get_button(GhosttyMouseEvent event,
|
|
GhosttyMouseButton *out_button);
|
|
|
|
/**
|
|
* Set keyboard modifiers held during the event.
|
|
*
|
|
* @param event The event handle, must not be NULL
|
|
* @param mods Modifier bitmask
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
GHOSTTY_API void ghostty_mouse_event_set_mods(GhosttyMouseEvent event,
|
|
GhosttyMods mods);
|
|
|
|
/**
|
|
* Get keyboard modifiers held during the event.
|
|
*
|
|
* @param event The event handle, must not be NULL
|
|
* @return Modifier bitmask
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
GHOSTTY_API GhosttyMods ghostty_mouse_event_get_mods(GhosttyMouseEvent event);
|
|
|
|
/**
|
|
* Set the event position in surface-space pixels.
|
|
*
|
|
* @param event The event handle, must not be NULL
|
|
* @param position The position to set
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
GHOSTTY_API void ghostty_mouse_event_set_position(GhosttyMouseEvent event,
|
|
GhosttyMousePosition position);
|
|
|
|
/**
|
|
* Get the event position in surface-space pixels.
|
|
*
|
|
* @param event The event handle, must not be NULL
|
|
* @return The current event position
|
|
*
|
|
* @ingroup mouse
|
|
*/
|
|
GHOSTTY_API GhosttyMousePosition ghostty_mouse_event_get_position(GhosttyMouseEvent event);
|
|
|
|
#endif /* GHOSTTY_VT_MOUSE_EVENT_H */
|