wlmaker
|
#include "container.h"
#include "element.h"
#include "input.h"
#include "util.h"
#include <math.h>
#include <stdlib.h>
#include <wayland-util.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/util/box.h>
#include <libbase/libbase.h>
Functions | |
static void | _wlmtk_element_get_pointer_area (wlmtk_element_t *element_ptr, int *x1_ptr, int *y1_ptr, int *x2_ptr, int *y2_ptr) |
static bool | _wlmtk_element_pointer_motion (wlmtk_element_t *element_ptr, wlmtk_pointer_motion_event_t *motion_event_ptr) |
static bool | _wlmtk_element_pointer_button (wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr) |
static bool | _wlmtk_element_pointer_axis (wlmtk_element_t *element_ptr, struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr) |
static void | _wlmtk_element_keyboard_blur (wlmtk_element_t *element_ptr) |
static bool | _wlmtk_element_keyboard_event (wlmtk_element_t *element_ptr, struct wlr_keyboard_key_event *wlr_keyboard_key_event_ptr, const xkb_keysym_t *key_syms, size_t key_syms_count, uint32_t modifiers) |
static void | handle_wlr_scene_node_destroy (struct wl_listener *listener_ptr, void *data_ptr) |
bool | wlmtk_element_init (wlmtk_element_t *element_ptr) |
wlmtk_element_vmt_t | wlmtk_element_extend (wlmtk_element_t *element_ptr, const wlmtk_element_vmt_t *element_vmt_ptr) |
void | wlmtk_element_fini (wlmtk_element_t *element_ptr) |
bs_dllist_node_t * | wlmtk_dlnode_from_element (wlmtk_element_t *element_ptr) |
wlmtk_element_t * | wlmtk_element_from_dlnode (bs_dllist_node_t *dlnode_ptr) |
void | wlmtk_element_set_parent_container (wlmtk_element_t *element_ptr, wlmtk_container_t *parent_container_ptr) |
void | wlmtk_element_attach_to_scene_graph (wlmtk_element_t *element_ptr) |
void | wlmtk_element_set_visible (wlmtk_element_t *element_ptr, bool visible) |
void | wlmtk_element_get_position (wlmtk_element_t *element_ptr, int *x_ptr, int *y_ptr) |
void | wlmtk_element_set_position (wlmtk_element_t *element_ptr, int x, int y) |
bool | wlmtk_element_pointer_motion (wlmtk_element_t *element_ptr, wlmtk_pointer_motion_event_t *motion_event_ptr) |
static void | fake_destroy (wlmtk_element_t *element_ptr) |
static struct wlr_scene_node * | fake_create_scene_node (wlmtk_element_t *element_ptr, struct wlr_scene_tree *wlr_scene_tree_ptr) |
static void | fake_get_dimensions (wlmtk_element_t *element_ptr, int *left_ptr, int *top_ptr, int *right_ptr, int *bottom_ptr) |
static void | fake_get_pointer_area (wlmtk_element_t *element_ptr, int *left_ptr, int *top_ptr, int *right_ptr, int *bottom_ptr) |
static bool | fake_pointer_motion (wlmtk_element_t *element_ptr, wlmtk_pointer_motion_event_t *motion_event_ptr) |
static bool | fake_pointer_button (wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr) |
static bool | fake_pointer_axis (wlmtk_element_t *element_ptr, struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr) |
static void | fake_pointer_grab_cancel (wlmtk_element_t *element_ptr) |
static void | fake_keyboard_blur (wlmtk_element_t *element_ptr) |
static bool | fake_keyboard_event (wlmtk_element_t *element_ptr, struct wlr_keyboard_key_event *wlr_keyboard_key_event_ptr, const xkb_keysym_t *key_syms, size_t key_syms_count, uint32_t modifiers) |
wlmtk_fake_element_t * | wlmtk_fake_element_create (void) |
void | wlmtk_fake_element_grab_keyboard (wlmtk_fake_element_t *fake_element_ptr) |
static void | test_init_fini (bs_test_t *test_ptr) |
static void | test_set_parent_container (bs_test_t *test_ptr) |
static void | test_set_get_position (bs_test_t *test_ptr) |
static void | test_get_dimensions (bs_test_t *test_ptr) |
static void | test_get_pointer_area (bs_test_t *test_ptr) |
static void | test_pointer_motion_leave (bs_test_t *test_ptr) |
static void | test_pointer_button (bs_test_t *test_ptr) |
static void | test_pointer_axis (bs_test_t *test_ptr) |
static void | test_keyboard_focus (bs_test_t *test_ptr) |
static void | test_keyboard_event (bs_test_t *test_ptr) |
Variables | |
static const wlmtk_element_vmt_t | element_vmt |
static const wlmtk_element_vmt_t | fake_element_vmt |
const bs_test_case_t | wlmtk_element_test_cases [] |
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.
|
static |
Wraps to wlmtk_element_vmt_t::get_dimensions as default implementation.
|
static |
Handler for losing keyboard focus. Nothing for default impl.
|
static |
Handler for keyboard events. By default: Nothing is handled.
|
static |
Does nothing, returns false.
|
static |
Does nothing, returns false.
|
static |
Stores pointer coordinates and timestamp. Returns true is x,y not NAN.
|
static |
A "fake" 'create_scene_node': Creates a non-attached buffer node.
|
static |
dtor for the "fake" element used for tests.
|
static |
A "fake" 'get_dimensions'.
|
static |
A "fake" 'get_pointer_area'.
|
static |
Registers losing keyboard focus.
|
static |
Handles 'keyboard_event' events for the fake element.
|
static |
Handles 'axis' events for the fake element.
|
static |
Handles 'button' events for the fake element.
|
static |
Records calls to wlmtk_element_vmt_t::pointer_grab_cancel.
|
static |
Handles 'motion' events for the fake element, updates last position.
|
static |
Handles the 'destroy' callback of the wlr_scene_node.
A call here indicates that teardown was not executed properly!
listener_ptr | |
data_ptr |
|
static |
Tests get_dimensions.
|
static |
Tests get_dimensions.
|
static |
Exercises init() and fini() methods, verifies dtor forwarding.
|
static |
Exercises "keyboard_event" method.
|
static |
Exercises keyboard grab & blur methods.
|
static |
Exercises "pointer_axis" method.
|
static |
Exercises "pointer_button" method.
|
static |
Verifies signals for "pointer_motion" and "pointer_leave".
|
static |
Tests get_position and set_position, and that scene graph follows.
|
static |
Tests set_parent_container, and that scene graph follows.
bs_dllist_node_t * wlmtk_dlnode_from_element | ( | wlmtk_element_t * | element_ptr | ) |
Gets the dlnode from the element.
void wlmtk_element_attach_to_scene_graph | ( | wlmtk_element_t * | element_ptr | ) |
Attaches or detaches the element to the parent's wlroots scene tree.
If the element has a parent, and that parent is itself attached to the wlroots scene tree, this will either re-parent an already existing node, or invoke wlmtk_element_vmt_t::create_scene_node to create and attach a new node to the paren'ts tree. Otherwise, it will clear any existing node.
The function is idempotent.
Private: Should only called by wlmtk_container_t methods, when there are changes to wlmtk_container_t::wlr_scene_tree.
element_ptr |
wlmtk_element_vmt_t wlmtk_element_extend | ( | wlmtk_element_t * | element_ptr, |
const wlmtk_element_vmt_t * | element_vmt_ptr | ||
) |
Extends the element's virtual methods.
element_ptr | |
element_vmt_ptr |
void wlmtk_element_fini | ( | wlmtk_element_t * | element_ptr | ) |
Cleans up the element.
element_ptr |
wlmtk_element_t * wlmtk_element_from_dlnode | ( | bs_dllist_node_t * | dlnode_ptr | ) |
Gets the element from the dlnode.
void wlmtk_element_get_position | ( | wlmtk_element_t * | element_ptr, |
int * | x_ptr, | ||
int * | y_ptr | ||
) |
Returns the position of the element.
element_ptr | |
x_ptr | Optional, may be NULL. |
y_ptr | Optional, may be NULL. |
bool wlmtk_element_init | ( | wlmtk_element_t * | element_ptr | ) |
Initializes the element.
element_ptr |
bool wlmtk_element_pointer_motion | ( | wlmtk_element_t * | element_ptr, |
wlmtk_pointer_motion_event_t * | pointer_motion_ptr | ||
) |
Passes a pointer motion event on to the element.
Will forward to wlmtk_element_vmt_t::pointer_motion, and (depending on that return value) trigger wlmtk_element_events_t::pointer_enter or wlmtk_element_events_t::pointer_leave.
element_ptr | |
pointer_motion_ptr |
void wlmtk_element_set_parent_container | ( | wlmtk_element_t * | element_ptr, |
wlmtk_container_t * | parent_container_ptr | ||
) |
Sets the parent container for the element.
Will call wlmtk_element_attach_to_scene_graph to align the scene graph with the new (or deleted) parent.
Private: Should only be called by wlmtk_container_add_element, respectively wlmtk_container_remove_element ("friends").
element_ptr | |
parent_container_ptr | Pointer to the parent container, or NULL if the parent should be cleared. |
void wlmtk_element_set_position | ( | wlmtk_element_t * | element_ptr, |
int | x, | ||
int | y | ||
) |
Sets the position of the element.
element_ptr | |
x | |
y |
void wlmtk_element_set_visible | ( | wlmtk_element_t * | element_ptr, |
bool | visible | ||
) |
Sets the element's visibility.
element_ptr | |
visible |
wlmtk_fake_element_t * wlmtk_fake_element_create | ( | void | ) |
Ctor for the fake element, useful for tests.
void wlmtk_fake_element_grab_keyboard | ( | wlmtk_fake_element_t * | fake_element_ptr | ) |
Sets wlmtk_fake_element_t::has_keyboard_focus and calls wlmtk_container_set_keyboard_focus_element for the parent (if set).
fake_element_ptr |
|
static |
Default virtual method table. Initializes the non-abstract methods.
|
static |
Virtual method table for the fake element.
const bs_test_case_t wlmtk_element_test_cases[] |
Unit tests for the element.