wlmaker
Loading...
Searching...
No Matches
element.h
Go to the documentation of this file.
1/* ========================================================================= */
20#ifndef __WLMTK_ELEMENT_H__
21#define __WLMTK_ELEMENT_H__
22
23#include <libbase/libbase.h>
24#include <stdbool.h>
25#include <stddef.h>
26#include <stdint.h>
27#include <wayland-server-core.h>
28#include <xkbcommon/xkbcommon.h>
29
30#define WLR_USE_UNSTABLE
31#include <wlr/util/box.h>
32#undef WLR_USE_UNSTABLE
33
34struct wlr_scene_tree;
35
40
44struct wlr_keyboard_key_event;
45
46#include "input.h"
47
48#define WLR_USE_UNSTABLE
49#include <wlr/types/wlr_pointer.h>
50#undef WLR_USE_UNSTABLE
51
52#ifdef __cplusplus
53extern "C" {
54#endif // __cplusplus
55
57typedef struct {
59 struct wl_signal pointer_enter;
61 struct wl_signal pointer_leave;
63 struct wl_signal pointer_motion;
65
69 void (*destroy)(wlmtk_element_t *element_ptr);
70
72 struct wlr_scene_node *(*create_scene_node)(
73 wlmtk_element_t *element_ptr,
74 struct wlr_scene_tree *wlr_scene_tree_ptr);
75
78 wlmtk_element_t *element_ptr,
79 int *x1_ptr,
80 int *y1_ptr,
81 int *x2_ptr,
82 int *y2_ptr);
83
97 wlmtk_element_t *element_ptr,
98 wlmtk_pointer_motion_event_t *motion_event_ptr);
99
111
121 wlmtk_element_t *element_ptr,
122 const wlmtk_button_event_t *button_event_ptr);
123
133 wlmtk_element_t *element_ptr,
134 struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr);
135
142 void (*keyboard_blur)(wlmtk_element_t *element_ptr);
143
156 wlmtk_element_t *element_ptr,
157 struct wlr_keyboard_key_event *wlr_keyboard_key_event_ptr);
158
174 wlmtk_element_t *element_ptr,
175 xkb_keysym_t keysym,
176 enum xkb_key_direction direction,
177 uint32_t modifiers);
178};
179
226
234bool wlmtk_element_init(wlmtk_element_t *element_ptr);
235
245 wlmtk_element_t *element_ptr,
246 const wlmtk_element_vmt_t *element_vmt_ptr);
247
254 wlmtk_element_t *element_ptr);
255
257bs_dllist_node_t *wlmtk_dlnode_from_element(
258 wlmtk_element_t *element_ptr);
261 bs_dllist_node_t *dlnode_ptr);
262
277 wlmtk_element_t *element_ptr,
278 wlmtk_container_t *parent_container_ptr);
279
297 wlmtk_element_t *element_ptr);
298
305void wlmtk_element_set_visible(wlmtk_element_t *element_ptr, bool visible);
306
315 wlmtk_element_t *element_ptr,
316 int *x_ptr,
317 int *y_ptr);
318
327 wlmtk_element_t *element_ptr,
328 int x,
329 int y);
330
341 wlmtk_element_t *element_ptr,
342 int *left_ptr,
343 int *top_ptr,
344 int *right_ptr,
345 int *bottom_ptr)
346{
347 element_ptr->vmt.get_dimensions(
348 element_ptr, left_ptr, top_ptr, right_ptr, bottom_ptr);
349}
350
359static inline struct wlr_box wlmtk_element_get_dimensions_box(
360 wlmtk_element_t *element_ptr)
361{
362 struct wlr_box box;
363 element_ptr->vmt.get_dimensions(
364 element_ptr, &box.x, &box.y, &box.width, &box.height);
365 box.width -= box.x;
366 box.height -= box.y;
367 return box;
368}
369
381 wlmtk_element_t *element_ptr,
382 wlmtk_pointer_motion_event_t *pointer_motion_ptr);
383
393 wlmtk_element_t *element_ptr,
394 const wlmtk_button_event_t *button_event_ptr);
395
405 wlmtk_element_t *element_ptr,
406 struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr);
407
421 wlmtk_element_t *element_ptr,
422 wlmtk_pointer_motion_event_t *motion_event_ptr);
423
433
440
443 wlmtk_element_t *element_ptr,
444 struct wlr_keyboard_key_event *wlr_keyboard_key_event_ptr)
445{
446 return element_ptr->vmt.keyboard_event(
447 element_ptr, wlr_keyboard_key_event_ptr);
448}
449
451static inline bool wlmtk_element_keyboard_sym(
452 wlmtk_element_t *element_ptr,
453 xkb_keysym_t keysym,
454 enum xkb_key_direction direction,
455 uint32_t modifiers)
456{
457 return element_ptr->vmt.keyboard_sym(
458 element_ptr, keysym, direction, modifiers);
459}
460
463 wlmtk_element_t *element_ptr)
464{
465 if (NULL != element_ptr->vmt.keyboard_blur) {
466 element_ptr->vmt.keyboard_blur(element_ptr);
467 }
468}
469
477static inline void wlmtk_element_destroy(
478 wlmtk_element_t *element_ptr) {
479 element_ptr->vmt.destroy(element_ptr);
480}
481
483extern const bs_test_case_t wlmtk_element_test_cases[];
484
515
524
534 wlmtk_fake_element_t *fake_element_ptr,
535 int width, int height);
536
544
545#ifdef __cplusplus
546} // extern "C"
547#endif // __cplusplus
548
549#endif /* __WLMTK_ELEMENT_H__ */
550/* == End of element.h ===================================================== */
void wlmtk_fake_element_grab_keyboard(wlmtk_fake_element_t *fake_element_ptr)
Definition element.c:501
bool wlmtk_element_init(wlmtk_element_t *element_ptr)
Definition element.c:72
wlmtk_fake_element_t * wlmtk_fake_element_create(void)
Definition element.c:470
static void wlmtk_element_get_dimensions(wlmtk_element_t *element_ptr, int *left_ptr, int *top_ptr, int *right_ptr, int *bottom_ptr)
Definition element.h:340
void wlmtk_element_fini(wlmtk_element_t *element_ptr)
Definition element.c:131
void wlmtk_element_pointer_grab_cancel(wlmtk_element_t *element_ptr)
Definition element.c:348
bool wlmtk_element_pointer_motion(wlmtk_element_t *element_ptr, wlmtk_pointer_motion_event_t *pointer_motion_ptr)
Definition element.c:264
bs_dllist_node_t * wlmtk_dlnode_from_element(wlmtk_element_t *element_ptr)
Definition element.c:142
static struct wlr_box wlmtk_element_get_dimensions_box(wlmtk_element_t *element_ptr)
Definition element.h:359
static void wlmtk_element_destroy(wlmtk_element_t *element_ptr)
Definition element.h:477
bool wlmtk_element_pointer_focus(wlmtk_element_t *element_ptr, wlmtk_pointer_motion_event_t *motion_event_ptr)
Definition element.c:310
const bs_test_case_t wlmtk_element_test_cases[]
Definition element.c:653
wlmtk_element_t * wlmtk_element_from_dlnode(bs_dllist_node_t *dlnode_ptr)
Definition element.c:149
void wlmtk_element_attach_to_scene_graph(wlmtk_element_t *element_ptr)
Definition element.c:166
static bool wlmtk_element_keyboard_sym(wlmtk_element_t *element_ptr, xkb_keysym_t keysym, enum xkb_key_direction direction, uint32_t modifiers)
Definition element.h:451
bool wlmtk_element_pointer_button(wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr)
Definition element.c:292
void wlmtk_element_pointer_blur(wlmtk_element_t *element_ptr)
Definition element.c:333
wlmtk_element_vmt_t wlmtk_element_extend(wlmtk_element_t *element_ptr, const wlmtk_element_vmt_t *element_vmt_ptr)
Definition element.c:87
void wlmtk_element_set_position(wlmtk_element_t *element_ptr, int x, int y)
Definition element.c:243
void wlmtk_element_set_visible(wlmtk_element_t *element_ptr, bool visible)
Definition element.c:210
bool wlmtk_element_pointer_axis(wlmtk_element_t *element_ptr, struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr)
Definition element.c:300
void wlmtk_element_set_parent_container(wlmtk_element_t *element_ptr, wlmtk_container_t *parent_container_ptr)
Definition element.c:156
void wlmtk_element_get_position(wlmtk_element_t *element_ptr, int *x_ptr, int *y_ptr)
Definition element.c:227
static bool wlmtk_element_keyboard_event(wlmtk_element_t *element_ptr, struct wlr_keyboard_key_event *wlr_keyboard_key_event_ptr)
Definition element.h:442
static void wlmtk_element_keyboard_blur(wlmtk_element_t *element_ptr)
Definition element.h:462
void wlmtk_fake_element_set_dimensions(wlmtk_fake_element_t *fake_element_ptr, int width, int height)
Definition element.c:488
Definition input.h:62
Definition container.h:55
Definition element.h:181
wlmtk_element_vmt_t vmt
Definition element.h:186
bool pointer_inside
Definition element.h:221
bool visible
Definition element.h:218
bs_dllist_node_t dlnode
Definition element.h:183
int y
Definition element.h:215
bool inhibit_pointer_blur
Definition element.h:224
struct wlr_scene_node * wlr_scene_node_ptr
Definition element.h:194
struct wl_listener wlr_scene_node_destroy_listener
Definition element.h:197
wlmtk_pointer_motion_event_t last_pointer_motion_event
Definition element.h:200
wlmtk_container_t * parent_container_ptr
Definition element.h:191
wlmtk_element_events_t events
Definition element.h:188
int x
Definition element.h:209
Definition element.h:67
bool(* keyboard_sym)(wlmtk_element_t *element_ptr, xkb_keysym_t keysym, enum xkb_key_direction direction, uint32_t modifiers)
Definition element.h:173
void(* pointer_grab_cancel)(wlmtk_element_t *element_ptr)
Definition element.h:110
void(* get_dimensions)(wlmtk_element_t *element_ptr, int *x1_ptr, int *y1_ptr, int *x2_ptr, int *y2_ptr)
Definition element.h:77
void(* keyboard_blur)(wlmtk_element_t *element_ptr)
Definition element.h:142
bool(* keyboard_event)(wlmtk_element_t *element_ptr, struct wlr_keyboard_key_event *wlr_keyboard_key_event_ptr)
Definition element.h:155
bool(* pointer_button)(wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr)
Definition element.h:120
bool(* pointer_axis)(wlmtk_element_t *element_ptr, struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr)
Definition element.h:132
void(* destroy)(wlmtk_element_t *element_ptr)
Definition element.h:69
bool(* pointer_accepts_motion)(wlmtk_element_t *element_ptr, wlmtk_pointer_motion_event_t *motion_event_ptr)
Definition element.h:96
Definition element.h:57
Definition element.h:486
bool pointer_grab_cancel_called
Definition element.h:504
bool keyboard_event_called
Definition element.h:508
bool has_keyboard_focus
Definition element.h:506
bool pointer_button_called
Definition element.h:498
wlmtk_element_vmt_t orig_vmt
Definition element.h:490
bool pointer_axis_called
Definition element.h:502
bool keyboard_sym_called
Definition element.h:510
wlmtk_element_t element
Definition element.h:488
wlmtk_button_event_t pointer_button_event
Definition element.h:500
bool pointer_accepts_motion_called
Definition element.h:495
Definition input.h:74