|
wlmaker
|
#include "container.h"#include <linux/input-event-codes.h>#include <math.h>#include <stdint.h>#include <stdlib.h>#include <toolkit/util.h>#include <wayland-util.h>#include <wlr/types/wlr_keyboard.h>#include <wlr/types/wlr_scene.h>#include <xkbcommon/xkbcommon.h>#include "input.h"
Classes | |
| struct | fake_parent_container_t |
Functions | |
| static void | _wlmtk_container_element_dlnode_destroy (bs_dllist_node_t *dlnode_ptr, void *ud_ptr) |
| static struct wlr_scene_node * | _wlmtk_container_element_create_scene_node (wlmtk_element_t *element_ptr, struct wlr_scene_tree *wlr_scene_tree_ptr) |
| static void | _wlmtk_container_element_get_dimensions (wlmtk_element_t *element_ptr, int *left_ptr, int *top_ptr, int *right_ptr, int *bottom_ptr) |
| static bool | _wlmtk_container_element_pointer_accepts_motion (wlmtk_element_t *element_ptr, wlmtk_pointer_motion_event_t *motion_event_ptr) |
| static bool | _wlmtk_container_element_pointer_button (wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr) |
| static bool | _wlmtk_container_element_pointer_axis (wlmtk_element_t *element_ptr, struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr) |
| static void | _wlmtk_container_element_pointer_grab_cancel (wlmtk_element_t *element_ptr) |
| static void | _wlmtk_container_element_keyboard_blur (wlmtk_element_t *element_ptr) |
| static bool | _wlmtk_container_element_keyboard_event (wlmtk_element_t *element_ptr, struct wlr_keyboard_key_event *wlr_keyboard_key_event_ptr) |
| static bool | _wlmtk_container_element_keyboard_sym (wlmtk_element_t *element_ptr, xkb_keysym_t keysym, enum xkb_key_direction direction, uint32_t modifiers) |
| static void | _wlmtk_container_element_layout (wlmtk_element_t *element_ptr) |
| static void | _wlmtk_container_handle_wlr_scene_tree_node_destroy (struct wl_listener *listener_ptr, void *data_ptr) |
| static void | _wlmtk_container_handle_element_pointer_leave (struct wl_listener *listener_ptr, void *data_ptr) |
| bool | wlmtk_container_init (wlmtk_container_t *container_ptr) |
| bool | wlmtk_container_init_attached (wlmtk_container_t *container_ptr, struct wlr_scene_tree *root_wlr_scene_tree_ptr) |
| void | wlmtk_container_fini (wlmtk_container_t *container_ptr) |
| void | wlmtk_container_add_element (wlmtk_container_t *container_ptr, wlmtk_element_t *element_ptr) |
| void | wlmtk_container_add_element_atop (wlmtk_container_t *container_ptr, wlmtk_element_t *reference_element_ptr, wlmtk_element_t *element_ptr) |
| void | wlmtk_container_remove_element (wlmtk_container_t *container_ptr, wlmtk_element_t *element_ptr) |
| void | wlmtk_container_raise_element_to_top (wlmtk_container_t *container_ptr, wlmtk_element_t *element_ptr) |
| bool | wlmtk_container_request_pointer_focus (wlmtk_container_t *container_ptr, wlmtk_element_t *element_ptr, wlmtk_pointer_motion_event_t *motion_event_ptr) |
| void | wlmtk_container_pointer_grab (wlmtk_container_t *container_ptr, wlmtk_element_t *element_ptr) |
| void | wlmtk_container_pointer_grab_release (wlmtk_container_t *container_ptr, wlmtk_element_t *element_ptr) |
| void | wlmtk_container_set_keyboard_focus_element (wlmtk_container_t *container_ptr, wlmtk_element_t *element_ptr, bool enabled) |
| void | wlmtk_container_invalidate_layout (wlmtk_container_t *container_ptr) |
| struct wlr_scene_tree * | wlmtk_container_wlr_scene_tree (wlmtk_container_t *container_ptr) |
| void | _wlmtk_container_element_run_layout (bs_dllist_node_t *dlnode_ptr, void *ud_ptr) |
| wlmtk_container_t * | wlmtk_container_create_fake_parent (void) |
| void | wlmtk_container_destroy_fake_parent (wlmtk_container_t *container_ptr) |
| static void | test_init_fini (bs_test_t *test_ptr) |
| static void | test_add_remove (bs_test_t *test_ptr) |
| static void | test_add_remove_with_scene_graph (bs_test_t *test_ptr) |
| static void | test_add_with_raise (bs_test_t *test_ptr) |
| static void | test_pointer_button (bs_test_t *test_ptr) |
| static void | test_pointer_grab (bs_test_t *test_ptr) |
| static void | test_pointer_grab_events (bs_test_t *test_ptr) |
| static void | test_keyboard_event (bs_test_t *test_ptr) |
| static void | test_keyboard_focus (bs_test_t *test_ptr) |
| static void | test_pointer_axis (bs_test_t *test_ptr) |
| static void | test_pointer_focus_with_parent (bs_test_t *test_ptr) |
| static void | test_pointer_focus_children (bs_test_t *test_ptr) |
| static void | test_pointer_focus_order (bs_test_t *test_ptr) |
Variables | |
| static const wlmtk_element_vmt_t | container_element_vmt |
| const bs_test_case_t | wlmtk_container_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 |
Implementation of the superclass wlmtk_element_t::create_scene_node method.
Creates the wlroots scene graph tree for the container, and will attach all already-contained elements to the scene graph, as well.
| element_ptr | |
| wlr_scene_tree_ptr |
|
static |
Calls dtor for wlmtk_element_t at dlnode_ptr in ud_ptr.
|
static |
Implementation of the element's get_dimensions method: Return dimensions.
| element_ptr | |
| left_ptr | Leftmost position. May be NULL. |
| top_ptr | Topmost position. May be NULL. |
| right_ptr | Rightmost position. Ma be NULL. |
| bottom_ptr | Bottommost position. May be NULL. |
|
static |
Implements wlmtk_element_vmt_t::keyboard_blur. Blurs all children.
|
static |
Handler for keyboard events: Pass to keyboard-focussed element, if any.
|
static |
Handler for translated keyboard events: To keyboard-focussed, if any.
|
static |
Imlements wlmtk_element_vmt_t::layout. Calls layout for each child.
|
static |
Implements wlmtk_element_vmt_t::pointer_accepts_motion.
| element_ptr | |
| motion_event_ptr |
|
static |
Implementation of the element's axis method: Handles axis events, by forwarding it to the element having pointer focus.
| element_ptr | |
| wlr_pointer_axis_event_ptr |
|
static |
Implementation of the element's pointer_button() method. Forwards it to the element currently having pointer focus.
| element_ptr | |
| button_event_ptr |
|
static |
Implements wlmtk_element_vmt_t::pointer_grab_cancel.
Cancels an existing pointer grab.
| element_ptr |
| void _wlmtk_container_element_run_layout | ( | bs_dllist_node_t * | dlnode_ptr, |
| void * | ud_ptr | ||
| ) |
Runs wlmtk_element_layout for each node element.
|
static |
Handles 'pointer_leave' events: Blurs element currently having focus.
|
static |
Handles the 'destroy' callback of wlr_scene_tree_ptr->node.
Will also detach (but not destroy) each of the still-contained elements.
| listener_ptr | |
| data_ptr |
|
static |
Exercises adding and removing elements, verifies destruction on fini.
|
static |
Tests that elements are attached, resp. detached from scene graph.
|
static |
Tests that elements inserted at position are also placed in scene graph.
|
static |
Exercises init() and fini() methods, verifies dtor forwarding.
|
static |
Tests that keyboard event are forwarded to element with keyboard focus.
|
static |
Test that keyboard focus is propagated and respects element removal.
|
static |
Tests that axis events are forwarded to element with pointer focus.
|
static |
Tests that pointer DOWN is forwarded to element with pointer focus.
|
static |
Tests moving pointer focus between children elements.
|
static |
Tests pointer focus when moving elements order (and position).
|
static |
Tests pointer focus.
|
static |
|
static |
Tests that element with the pointer grab receives pointer events.
| void wlmtk_container_add_element | ( | wlmtk_container_t * | container_ptr, |
| wlmtk_element_t * | element_ptr | ||
| ) |
Adds element_ptr to the container.
Requires that element_ptr is not added to a container yet. The element will be added at the top of the container.
| container_ptr | |
| element_ptr |
| void wlmtk_container_add_element_atop | ( | wlmtk_container_t * | container_ptr, |
| wlmtk_element_t * | reference_element_ptr, | ||
| wlmtk_element_t * | element_ptr | ||
| ) |
Adds element_ptr to the container atop the reference's position.
If reference_element_ptr is NULL, the element will be added at the back.
| container_ptr | |
| reference_element_ptr | Must be an element of this container. |
| element_ptr |
| wlmtk_container_t * wlmtk_container_create_fake_parent | ( | void | ) |
Constructor for a fake container with a scene tree.
| void wlmtk_container_destroy_fake_parent | ( | wlmtk_container_t * | container_ptr | ) |
Destructor for that fake container.
| void wlmtk_container_fini | ( | wlmtk_container_t * | container_ptr | ) |
Un-initializes the container.
Any element still in elements will be destroyed.
| container_ptr |
| bool wlmtk_container_init | ( | wlmtk_container_t * | container_ptr | ) |
Initializes the container with the provided virtual method table.
| container_ptr |
| bool wlmtk_container_init_attached | ( | wlmtk_container_t * | container_ptr, |
| struct wlr_scene_tree * | root_wlr_scene_tree_ptr | ||
| ) |
Initializes the container, and attach to WLR sene graph.
| container_ptr | |
| root_wlr_scene_tree_ptr |
| void wlmtk_container_invalidate_layout | ( | wlmtk_container_t * | container_ptr | ) |
Informs the container (and parents) that the layout needs to be recomputed.
Must be called if an element is added or removed, or if any of the child elements changes visibility or dimensions. Propagates to the parent container(s).
| container_ptr |
| void wlmtk_container_pointer_grab | ( | wlmtk_container_t * | container_ptr, |
| wlmtk_element_t * | element_ptr | ||
| ) |
Requests a pointer grab from container_ptr for element_ptr.
Will cancel any existing grab held by elements other than element_ptr, and propagates the grab to the parent container. When a pointer grab is held, pointer events will be routed exclusively to the element holding the pointer grab.
| container_ptr | |
| element_ptr | Must be a child of this container. |
| void wlmtk_container_pointer_grab_release | ( | wlmtk_container_t * | container_ptr, |
| wlmtk_element_t * | element_ptr | ||
| ) |
Releases a pointer grab in container_ptr held by element_ptr.
If the grab is held by an element other than element_ptr, nothing is done. Otherwise, the pointer grab is released, and the release is propagated to the parent container.
| container_ptr | |
| element_ptr | Must be a child of this container. |
| void wlmtk_container_raise_element_to_top | ( | wlmtk_container_t * | container_ptr, |
| wlmtk_element_t * | element_ptr | ||
| ) |
Places element_ptr at the top (head) of the container.
Expects that container_ptr is element_ptr's parent container.
| container_ptr | |
| element_ptr |
| void wlmtk_container_remove_element | ( | wlmtk_container_t * | container_ptr, |
| wlmtk_element_t * | element_ptr | ||
| ) |
Removes element_ptr from the container.
Expects that container_ptr is element_ptr's parent container. In case element_ptr holds a pointer grab, wlmtk_element_pointer_grab_cancel will be called.
| container_ptr | |
| element_ptr |
| bool wlmtk_container_request_pointer_focus | ( | wlmtk_container_t * | container_ptr, |
| wlmtk_element_t * | element_ptr, | ||
| wlmtk_pointer_motion_event_t * | motion_event_ptr | ||
| ) |
Requests that element_ptr be given pointer focus from container_ptr.
| container_ptr | |
| element_ptr | Must be in wlmtk_container_t::elements. |
| motion_event_ptr | The motion event (in particular: pointer) that led to request pointer focus. FIXME -> Must change to pointer! |
| void wlmtk_container_set_keyboard_focus_element | ( | wlmtk_container_t * | container_ptr, |
| wlmtk_element_t * | element_ptr, | ||
| bool | enabled | ||
| ) |
Sets or disables keyboard focus for element_ptr for the container.
If enabled, calls wlmtk_element_keyboard_blur for the element currently having keyboard focus, and updates wlmtk_container_t::keyboard_focus_element_ptr to element_ptr. Otherwise, evaluates whether the focus is currently held by element_ptr, and (if yes) clears this container's focus. Propagates the event to the container's parent.
| container_ptr | |
| element_ptr | |
| enabled |
| struct wlr_scene_tree * wlmtk_container_wlr_scene_tree | ( | wlmtk_container_t * | container_ptr | ) |
Returns the wlroots scene graph tree for this node.
Private: Should be called only by wlmtk_element_t.
| container_ptr |
|
static |
Virtual method table for the container's super class: Element.
| const bs_test_case_t wlmtk_container_test_cases[] |
Unit tests for the container.