wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
cursor.c File Reference
#include "cursor.h"
#include <ini.h>
#include <inttypes.h>
#include <libbase/libbase.h>
#include <libbase/plist.h>
#include <linux/input-event-codes.h>
#include <stdlib.h>
#include <string.h>
#include <wayland-server-core.h>
#include <wayland-server-protocol.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include "keyboard.h"
#include "toolkit/toolkit.h"
Include dependency graph for cursor.c:

Classes

struct  _wlmim_cursor_t
 

Functions

static void _wlmim_cursor_handle_motion (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmim_cursor_handle_motion_absolute (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmim_cursor_handle_button (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmim_cursor_handle_axis (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmim_cursor_handle_frame (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmim_cursor_handle_seat_request_set_cursor (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmim_cursor_process_motion (wlmim_cursor_t *cursor_ptr, uint32_t time_msec)
 
char * _wlmim_cursor_get_theme_name (const struct wlmim_cursor_style *style_ptr)
 
static int _wlmim_cursor_theme_handler (void *ud_ptr, const char *section_ptr, const char *name_ptr, const char *value_ptr)
 
wlmim_cursor_twlmim_cursor_create (wlmim_t *input_manager_ptr, const struct wlmim_cursor_style *style_ptr, const struct wlmim_cursor_options *options_ptr, struct wlr_output_layout *wlr_output_layout_ptr, struct wlr_seat *wlr_seat_ptr, wlmtk_root_t *root_ptr)
 
void wlmim_cursor_destroy (wlmim_cursor_t *cursor_ptr)
 
bool wlmim_cursor_set_style (wlmim_cursor_t *cursor_ptr, const struct wlmim_cursor_style *style_ptr)
 
struct wlr_cursor * wlmim_cursor_wlr_cursor (wlmim_cursor_t *cursor_ptr)
 
void wlmim_cursor_attach_input_device (wlmim_cursor_t *cursor_ptr, struct wlr_input_device *wlr_input_device_ptr)
 
void wlmim_cursor_detach_input_device (wlmim_cursor_t *cursor_ptr, struct wlr_input_device *wlr_input_device_ptr)
 
static void _wlmim_cursor_test_theme_name (bs_test_t *test_ptr)
 
static void _wlmim_cursor_test_config (bs_test_t *test_ptr)
 

Variables

const bspl_desc_t wlmim_cursor_style_desc []
 
const bspl_desc_t wlmim_cursor_options_desc []
 
static const char * _wlmim_cursor_system_config_file
 
static const char * _wlmim_cursor_system_config_alternative_file
 
static const bs_test_case_t _wlmim_cursor_test_cases []
 
const bs_test_set_t wlmim_cursor_test_set
 

Detailed Description

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ _wlmim_cursor_get_theme_name()

char * _wlmim_cursor_get_theme_name ( const struct wlmim_cursor_style style_ptr)

Returns a copy of the cursor theme's name to use, from configured style.

This will either be a copy of wlmim_cursor_style::name_ptr, or what is described by the system-wide cursor theme files.

Parameters
style_ptr
Returns
Cursor theme name, as string. Must be released via free().

◆ _wlmim_cursor_handle_axis()

void _wlmim_cursor_handle_axis ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handler for the axis event of wlr_cursor.

Parameters
listener_ptr
data_ptrPoints to a wlr_pointer_axis_event.

◆ _wlmim_cursor_handle_button()

void _wlmim_cursor_handle_button ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handler for the button event of wlr_cursor.

Parameters
listener_ptr
data_ptrPoints to a wlr_pointer_button_event.

◆ _wlmim_cursor_handle_frame()

void _wlmim_cursor_handle_frame ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handler for the frame event of wlr_cursor.

Parameters
listener_ptr
data_ptr

◆ _wlmim_cursor_handle_motion()

void _wlmim_cursor_handle_motion ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handler for the motion event of wlr_cursor.

Parameters
listener_ptr
data_ptrPoints to a wlr_pointer_motion_event.

◆ _wlmim_cursor_handle_motion_absolute()

void _wlmim_cursor_handle_motion_absolute ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handler for the motion_absolute event of wlr_cursor.

Parameters
listener_ptr
data_ptrPoints to a wlr_pointer_motion_absolute_event.

◆ _wlmim_cursor_handle_seat_request_set_cursor()

void _wlmim_cursor_handle_seat_request_set_cursor ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handler for the request_set_cursor event of wlr_seat.

This event is raised when a client provides a cursor image. It is accepted only if the client also has the pointer focus.

Parameters
listener_ptr
data_ptrPoints to a wlr_seat_pointer_request_set_cursor_event.

◆ _wlmim_cursor_process_motion()

void _wlmim_cursor_process_motion ( wlmim_cursor_t cursor_ptr,
uint32_t  time_msec 
)
static

Processes the cursor motion: Lookups up the view & surface under the pointer and sets (respectively: clears) the pointer focus. Also sets the default cursor image, if no view is given (== no client-side cursor).

Parameters
cursor_ptr
time_msec

◆ _wlmim_cursor_test_config()

void _wlmim_cursor_test_config ( bs_test_t *  test_ptr)
static

Tests that parsing the configuration populates the options.

◆ _wlmim_cursor_test_theme_name()

void _wlmim_cursor_test_theme_name ( bs_test_t *  test_ptr)
static

Tests obtaining the theme name.

◆ _wlmim_cursor_theme_handler()

int _wlmim_cursor_theme_handler ( void *  ud_ptr,
const char *  section_ptr,
const char *  name_ptr,
const char *  value_ptr 
)
static

inih library parser callback for the system-wide cursor theme files.

◆ wlmim_cursor_attach_input_device()

void wlmim_cursor_attach_input_device ( wlmim_cursor_t cursor_ptr,
struct wlr_input_device *  wlr_input_device_ptr 
)

Attaches the input device. May be a pointer, touch or tablet_tool device.

Parameters
cursor_ptr
wlr_input_device_ptr

◆ wlmim_cursor_create()

wlmim_cursor_t * wlmim_cursor_create ( wlmim_t input_manager_ptr,
const struct wlmim_cursor_style style_ptr,
const struct wlmim_cursor_options options_ptr,
struct wlr_output_layout *  wlr_output_layout_ptr,
struct wlr_seat *  wlr_seat_ptr,
wlmtk_root_t root_ptr 
)

Creates the cursor handlers.

Parameters
input_manager_ptr
style_ptr
options_ptr
wlr_output_layout_ptr
wlr_seat_ptr
root_ptr
Returns
The cursor handler or NULL on error.

◆ wlmim_cursor_destroy()

void wlmim_cursor_destroy ( wlmim_cursor_t cursor_ptr)

Destroys the cursor handlers.

Parameters
cursor_ptr

◆ wlmim_cursor_detach_input_device()

void wlmim_cursor_detach_input_device ( wlmim_cursor_t cursor_ptr,
struct wlr_input_device *  wlr_input_device_ptr 
)

Detaches the input device.

See also
wlmim_cursor_attach_input_device.
Parameters
cursor_ptr
wlr_input_device_ptr

◆ wlmim_cursor_set_style()

bool wlmim_cursor_set_style ( wlmim_cursor_t cursor_ptr,
const struct wlmim_cursor_style style_ptr 
)

Updates the cursor's style.

Parameters
cursor_ptr
style_ptr
Returns
true on success.

◆ wlmim_cursor_wlr_cursor()

struct wlr_cursor * wlmim_cursor_wlr_cursor ( wlmim_cursor_t cursor_ptr)

Variable Documentation

◆ _wlmim_cursor_system_config_alternative_file

const char* _wlmim_cursor_system_config_alternative_file
static
Initial value:
=
"/etc/alternatives/x-cursor-theme"

The debian specific versino of the system-wide cursor configuration.

◆ _wlmim_cursor_system_config_file

const char* _wlmim_cursor_system_config_file
static
Initial value:
=
"/usr/share/icons/default/index.theme"

Name of the system-wide configuration file for cursor themes.

◆ _wlmim_cursor_test_cases

const bs_test_case_t _wlmim_cursor_test_cases[]
static
Initial value:
= {
{ 1, "theme_name", _wlmim_cursor_test_theme_name },
{ 1, "config", _wlmim_cursor_test_config },
}
static void _wlmim_cursor_test_config(bs_test_t *test_ptr)
Definition cursor.c:606
static void _wlmim_cursor_test_theme_name(bs_test_t *test_ptr)
Definition cursor.c:585

Unit test cases.

◆ wlmim_cursor_options_desc

const bspl_desc_t wlmim_cursor_options_desc[]
Initial value:
= {
BSPL_DESC_ENUM("EmulateRightButtonModifier", false,
struct wlmim_cursor_options, emulate_right_button_modifier,
emulate_right_button_modifier, 0,
BSPL_DESC_ENUM("MoveWindowModifier", false,
struct wlmim_cursor_options, move_window_modifier,
move_window_modifier, 0,
BSPL_DESC_SENTINEL(),
}
const bspl_enum_desc_t wlmim_keyboard_modifiers[]
Definition keyboard.c:83
Definition cursor.h:54

Descriptor for decoding Cursor-relevant config dictionary.

◆ wlmim_cursor_style_desc

const bspl_desc_t wlmim_cursor_style_desc[]
Initial value:
= {
BSPL_DESC_BOOL(
"OverrideSystemConfiguration", false, struct wlmim_cursor_style,
override_system_configuration, override_system_configuration, false),
BSPL_DESC_STRING(
"Name", true, struct wlmim_cursor_style, name_ptr, name_ptr,
"default"),
BSPL_DESC_UINT64(
"Size", true, struct wlmim_cursor_style, size, size, 24),
}
Definition cursor.h:44

Descriptor for decoding the "Cursor" style dictionary.

◆ wlmim_cursor_test_set

const bs_test_set_t wlmim_cursor_test_set
Initial value:
= BS_TEST_SET(
true, "cursor", _wlmim_cursor_test_cases)
static const bs_test_case_t _wlmim_cursor_test_cases[]
Definition cursor.c:574

Unit tests for cursor.