wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
element.h File Reference
#include <libbase/libbase.h>
#include <wayland-server.h>
#include "wlr/util/box.h"
#include "env.h"
#include "input.h"
#include <wlr/types/wlr_pointer.h>
Include dependency graph for element.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _wlmtk_element_vmt_t
 
struct  _wlmtk_element_t
 
struct  wlmtk_fake_element_t
 

Typedefs

typedef struct _wlmtk_element_t wlmtk_element_t
 
typedef struct _wlmtk_element_vmt_t wlmtk_element_vmt_t
 
typedef struct _wlmtk_container_t wlmtk_container_t
 

Functions

bool wlmtk_element_init (wlmtk_element_t *element_ptr, wlmtk_env_t *env_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_twlmtk_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)
 
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 void wlmtk_element_get_dimensions (wlmtk_element_t *element_ptr, int *left_ptr, int *top_ptr, int *right_ptr, int *bottom_ptr)
 
static struct wlr_box wlmtk_element_get_dimensions_box (wlmtk_element_t *element_ptr)
 
bool wlmtk_element_pointer_motion (wlmtk_element_t *element_ptr, double x, double y, uint32_t time_msec)
 
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_destroy (wlmtk_element_t *element_ptr)
 
wlmtk_fake_element_twlmtk_fake_element_create (void)
 

Variables

const bs_test_case_t wlmtk_element_test_cases []
 

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.

Typedef Documentation

◆ wlmtk_container_t

Forward declaration: Container.

◆ wlmtk_element_t

Forward declaration: Element.

◆ wlmtk_element_vmt_t

Forward declaration: Element virtual method table.

Function Documentation

◆ wlmtk_dlnode_from_element()

bs_dllist_node_t * wlmtk_dlnode_from_element ( wlmtk_element_t * element_ptr)

Gets the dlnode from the element.

◆ wlmtk_element_attach_to_scene_graph()

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.

Parameters
element_ptr

◆ wlmtk_element_destroy()

static void wlmtk_element_destroy ( wlmtk_element_t * element_ptr)
inlinestatic

Virtual method: Calls the dtor of the element's implementation.

The implementation is required to call wlmtk_element_fini().

Parameters
element_ptr

◆ wlmtk_element_extend()

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.

Parameters
element_ptr
element_vmt_ptr
Returns
The previous virtual method table.

◆ wlmtk_element_fini()

void wlmtk_element_fini ( wlmtk_element_t * element_ptr)

Cleans up the element.

Parameters
element_ptr

◆ wlmtk_element_from_dlnode()

wlmtk_element_t * wlmtk_element_from_dlnode ( bs_dllist_node_t * dlnode_ptr)

Gets the element from the dlnode.

◆ wlmtk_element_get_dimensions()

static void wlmtk_element_get_dimensions ( wlmtk_element_t * element_ptr,
int * left_ptr,
int * top_ptr,
int * right_ptr,
int * bottom_ptr )
inlinestatic

Gets the dimensions of the element in pixels, relative to the position.

Parameters
element_ptr
left_ptrLeftmost position. May be NULL.
top_ptrTopmost position. May be NULL.
right_ptrRightmost position. Ma be NULL.
bottom_ptrBottommost position. May be NULL.

◆ wlmtk_element_get_dimensions_box()

static struct wlr_box wlmtk_element_get_dimensions_box ( wlmtk_element_t * element_ptr)
inlinestatic

Gets the element's dimensions in pixel as wlr_box, relative to the position.

Parameters
element_ptr
Returns
A struct wlr_box that specifies the top-left corner of the element relative to it's position, and the element's total width and height.

◆ wlmtk_element_get_pointer_area()

static void wlmtk_element_get_pointer_area ( wlmtk_element_t * element_ptr,
int * x1_ptr,
int * y1_ptr,
int * x2_ptr,
int * y2_ptr )
inlinestatic

Gets the area that the element on which the element accepts pointer events.

The area extents are relative to the element's position. By default, this overlaps with the element dimensions. Some elements (eg. a surface with further-extending sub-surfaces) may differ.

Parameters
element_ptr
x1_ptrLeftmost position of pointer area. May be NULL.
y1_ptrTopmost position of pointer area. May be NULL.
x2_ptrRightmost position of pointer area. May be NULL.
y2_ptrBottommost position of pointer area. May be NULL.

◆ wlmtk_element_get_position()

void wlmtk_element_get_position ( wlmtk_element_t * element_ptr,
int * x_ptr,
int * y_ptr )

Returns the position of the element.

Parameters
element_ptr
x_ptrOptional, may be NULL.
y_ptrOptional, may be NULL.

◆ wlmtk_element_init()

bool wlmtk_element_init ( wlmtk_element_t * element_ptr,
wlmtk_env_t * env_ptr )

Initializes the element.

Parameters
element_ptr
env_ptr
Returns
true on success.

◆ wlmtk_element_pointer_axis()

static bool wlmtk_element_pointer_axis ( wlmtk_element_t * element_ptr,
struct wlr_pointer_axis_event * wlr_pointer_axis_event_ptr )
inlinestatic

◆ wlmtk_element_pointer_button()

static bool wlmtk_element_pointer_button ( wlmtk_element_t * element_ptr,
const wlmtk_button_event_t * button_event_ptr )
inlinestatic

◆ wlmtk_element_pointer_motion()

bool wlmtk_element_pointer_motion ( wlmtk_element_t * element_ptr,
double x,
double y,
uint32_t time_msec )

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_vmt_t::pointer_enter of wlmtk_element_vmt_t::pointer_leave calls.

Parameters
element_ptr
x
y
time_msec

◆ wlmtk_element_set_parent_container()

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").

Parameters
element_ptr
parent_container_ptrPointer to the parent container, or NULL if the parent should be cleared.

◆ wlmtk_element_set_position()

void wlmtk_element_set_position ( wlmtk_element_t * element_ptr,
int x,
int y )

Sets the position of the element.

Parameters
element_ptr
x
y

◆ wlmtk_element_set_visible()

void wlmtk_element_set_visible ( wlmtk_element_t * element_ptr,
bool visible )

Sets the element's visibility.

Parameters
element_ptr
visible

◆ wlmtk_fake_element_create()

wlmtk_fake_element_t * wlmtk_fake_element_create ( void )

Ctor for the fake element, useful for tests.

Returns
A pointer to wlmtk_fake_element_t. Should be destroyed via wlmtk_element_destroy, by passing the pointer to wlmtk_fake_element_t::element as argument.

Variable Documentation

◆ wlmtk_element_test_cases

const bs_test_case_t wlmtk_element_test_cases[]
extern

Unit tests for the element.