wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
root.c File Reference
#include "root.h"
#include <wlr/version.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_scene.h>
Include dependency graph for root.c:

Classes

struct  _wlmtk_root_t
 
struct  _wlmtk_root_test_workspace_t
 

Functions

static void _wlmtk_root_switch_to_workspace (wlmtk_root_t *root_ptr, wlmtk_workspace_t *workspace_ptr)
 
static void _wlmtk_root_set_workspace_extents (bs_dllist_node_t *dlnode_ptr, void *ud_ptr)
 
static void _wlmtk_root_enumerate_workspaces (bs_dllist_node_t *dlnode_ptr, void *ud_ptr)
 
static void _wlmtk_root_destroy_workspace (bs_dllist_node_t *dlnode_ptr, void *ud_ptr)
 
static bool _wlmtk_root_element_pointer_motion (wlmtk_element_t *element_ptr, double x, double y, uint32_t time_msec)
 
static bool _wlmtk_root_element_pointer_button (wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr)
 
static bool _wlmtk_root_element_pointer_axis (wlmtk_element_t *element_ptr, struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr)
 
static bool _wlmtk_root_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)
 
wlmtk_root_twlmtk_root_create (struct wlr_scene *wlr_scene_ptr, wlmtk_env_t *env_ptr)
 
void wlmtk_root_destroy (wlmtk_root_t *root_ptr)
 
wlmtk_root_events_twlmtk_root_events (wlmtk_root_t *root_ptr)
 
void wlmtk_root_set_extents (wlmtk_root_t *root_ptr, const struct wlr_box *extents_ptr)
 
bool wlmtk_root_pointer_motion (wlmtk_root_t *root_ptr, double x, double y, uint32_t time_msec)
 
bool wlmtk_root_pointer_button (wlmtk_root_t *root_ptr, const struct wlr_pointer_button_event *event_ptr)
 
bool wlmtk_root_pointer_axis (wlmtk_root_t *root_ptr, struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr)
 
void wlmtk_root_add_workspace (wlmtk_root_t *root_ptr, wlmtk_workspace_t *workspace_ptr)
 
void wlmtk_root_remove_workspace (wlmtk_root_t *root_ptr, wlmtk_workspace_t *workspace_ptr)
 
wlmtk_workspace_twlmtk_root_get_current_workspace (wlmtk_root_t *root_ptr)
 
void wlmtk_root_switch_to_next_workspace (wlmtk_root_t *root_ptr)
 
void wlmtk_root_switch_to_previous_workspace (wlmtk_root_t *root_ptr)
 
bool wlmtk_root_lock (wlmtk_root_t *root_ptr, wlmtk_lock_t *lock_ptr)
 
bool wlmtk_root_unlock (wlmtk_root_t *root_ptr, wlmtk_lock_t *lock_ptr)
 
void wlmtk_root_lock_unreference (wlmtk_root_t *root_ptr, wlmtk_lock_t *lock_ptr)
 
void wlmtk_root_set_lock_surface (wlmtk_root_t *root_ptr, wlmtk_surface_t *surface_ptr)
 
wlmtk_element_twlmtk_root_element (wlmtk_root_t *root_ptr)
 
static void test_create_destroy (bs_test_t *test_ptr)
 
static void test_workspaces (bs_test_t *test_ptr)
 
static void test_pointer_button (bs_test_t *test_ptr)
 
static void _wlmtk_root_test_workspace_changed_handler (struct wl_listener *listener_ptr, void *data_ptr)
 

Variables

static const wlmtk_element_vmt_t _wlmtk_root_element_vmt
 
const bs_test_case_t wlmtk_root_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.

Function Documentation

◆ _wlmtk_root_destroy_workspace()

void _wlmtk_root_destroy_workspace ( bs_dllist_node_t * dlnode_ptr,
void * ud_ptr )
static

Callback for bs_dllist_for_each: Destroys the workspace.

◆ _wlmtk_root_element_keyboard_event()

bool _wlmtk_root_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

Implements wlmtk_element_vmt_t::keyboard_event. Handle keyboard events.

When locked, the root container will forward the events strictly only to the lock container.

Parameters
element_ptr
wlr_keyboard_key_event_ptr
key_syms
key_syms_count
modifiers
Returns
true if the axis event was handled.

◆ _wlmtk_root_element_pointer_axis()

bool _wlmtk_root_element_pointer_axis ( wlmtk_element_t * element_ptr,
struct wlr_pointer_axis_event * wlr_pointer_axis_event_ptr )
static

Implements wlmtk_element_vmt_t::pointer_axis. Handle axis events.

When locked, the root container will forward the events strictly only to the lock container.

Parameters
element_ptr
wlr_pointer_axis_event_ptr
Returns
true if the axis event was handled.

◆ _wlmtk_root_element_pointer_button()

bool _wlmtk_root_element_pointer_button ( wlmtk_element_t * element_ptr,
const wlmtk_button_event_t * button_event_ptr )
static

Implements wlmtk_element_vmt_t::pointer_button. Handle button events.

When locked, the root container will forward the events strictly only to the lock container.

Parameters
element_ptr
button_event_ptr
Returns
true if the button was handled.

◆ _wlmtk_root_element_pointer_motion()

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

Implements wlmtk_element_vmt_t::pointer_motion. Handle pointer moves.

When locked, the root container will forward the events strictly only to the lock container.

Parameters
element_ptr
x
y
time_msec
Returns
Whether the move was accepted.

◆ _wlmtk_root_enumerate_workspaces()

void _wlmtk_root_enumerate_workspaces ( bs_dllist_node_t * dlnode_ptr,
void * ud_ptr )
static

Callback for bs_dllist_for_each: Enumerates the workspace.

◆ _wlmtk_root_set_workspace_extents()

void _wlmtk_root_set_workspace_extents ( bs_dllist_node_t * dlnode_ptr,
void * ud_ptr )
static

Callback for bs_dllist_for_each to set extents of the workspace.

Parameters
dlnode_ptr
ud_ptr

◆ _wlmtk_root_switch_to_workspace()

void _wlmtk_root_switch_to_workspace ( wlmtk_root_t * root_ptr,
wlmtk_workspace_t * workspace_ptr )
static

Switches to workspace_ptr as the current workspace.

Parameters
root_ptr
workspace_ptr

◆ _wlmtk_root_test_workspace_changed_handler()

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

Test helper callback for wlmtk_root_events_t::workspace_changed.

◆ test_create_destroy()

void test_create_destroy ( bs_test_t * test_ptr)
static

Exercises ctor and dtor.

◆ test_pointer_button()

void test_pointer_button ( bs_test_t * test_ptr)
static

Tests wlmtk_root_pointer_button.

◆ test_workspaces()

void test_workspaces ( bs_test_t * test_ptr)
static

Exercises workspace adding and removal.

◆ wlmtk_root_add_workspace()

void wlmtk_root_add_workspace ( wlmtk_root_t * root_ptr,
wlmtk_workspace_t * workspace_ptr )

Adds a workspace.

Parameters
root_ptr
workspace_ptr

◆ wlmtk_root_create()

wlmtk_root_t * wlmtk_root_create ( struct wlr_scene * wlr_scene_ptr,
wlmtk_env_t * env_ptr )

Creates the root element.

Parameters
wlr_scene_ptr
env_ptr
Returns
Handle of the root element or NULL on error.

◆ wlmtk_root_destroy()

void wlmtk_root_destroy ( wlmtk_root_t * root_ptr)

Destroys the root element.

Parameters
root_ptr

◆ wlmtk_root_element()

wlmtk_element_t * wlmtk_root_element ( wlmtk_root_t * root_ptr)
Returns
pointer to the root's wlmtk_element_t. (Temporary)

◆ wlmtk_root_events()

wlmtk_root_events_t * wlmtk_root_events ( wlmtk_root_t * root_ptr)

Gets the set of events available in root. To bind listeners to.

Parameters
root_ptr
Returns
Pointer to wlmtk_root_t::events.

◆ wlmtk_root_get_current_workspace()

wlmtk_workspace_t * wlmtk_root_get_current_workspace ( wlmtk_root_t * root_ptr)

Returns a pointer to the currently-active workspace.

Parameters
root_ptr

◆ wlmtk_root_lock()

bool wlmtk_root_lock ( wlmtk_root_t * root_ptr,
wlmtk_lock_t * lock_ptr )

Locks the root, using the provided lock.

The root must not be locked already. If locked successfully, the root will keep a reference to lock_ptr. The lock must call wlmtk_root_unlock to unlock root, and for releasing the reference.

Parameters
root_ptr
lock_ptr
Returns
Whether the lock was established.

◆ wlmtk_root_lock_unreference()

void wlmtk_root_lock_unreference ( wlmtk_root_t * root_ptr,
wlmtk_lock_t * lock_ptr )

Releases the lock reference, but keeps the root locked.

This is in accordance with the session lock protocol specification [1], stating the session should remain locked if the client dies. This call is a no-op if lock_ptr is not currently the lock of root_ptr.

[1] https://wayland.app/protocols/ext-session-lock-v1

Parameters
root_ptr
lock_ptr

◆ wlmtk_root_pointer_axis()

bool wlmtk_root_pointer_axis ( wlmtk_root_t * root_ptr,
struct wlr_pointer_axis_event * wlr_pointer_axis_event_ptr )

Handles a pointer axis event.

Parameters
root_ptr
wlr_pointer_axis_event_ptr
Returns
Whether the axis event was consumed.

◆ wlmtk_root_pointer_button()

bool wlmtk_root_pointer_button ( wlmtk_root_t * root_ptr,
const struct wlr_pointer_button_event * event_ptr )

Handles a button event: Translates to button down/up/click/dblclick events.

Each button activity (button pressed or released) will directly trigger a corresponding BUTTON_DOWN or BUTTON_UP event. Depending on timing and motion, a "released" event may also triccer a CLICK, DOUBLE_CLICK or DRAG event. These events will be forwarded to the event currently having pointer focus.

TODO(kaese.nosp@m.r@gu.nosp@m.bbe.c.nosp@m.h): Implement DOUBLE_CLICK and DRAG events, and make it well tested.

Parameters
root_ptr
event_ptr
Returns
Whether the button was consumed.

◆ wlmtk_root_pointer_motion()

bool wlmtk_root_pointer_motion ( wlmtk_root_t * root_ptr,
double x,
double y,
uint32_t time_msec )

Handles a pointer motion event.

Parameters
root_ptr
x
y
time_msec
Returns
Whether there was an element under the pointer.

◆ wlmtk_root_remove_workspace()

void wlmtk_root_remove_workspace ( wlmtk_root_t * root_ptr,
wlmtk_workspace_t * workspace_ptr )

Removes the workspace.

Parameters
root_ptr
workspace_ptr

◆ wlmtk_root_set_extents()

void wlmtk_root_set_extents ( wlmtk_root_t * root_ptr,
const struct wlr_box * extents_ptr )

Sets the extents of root (and all workspaces thereof).

Parameters
root_ptr
extents_ptr

◆ wlmtk_root_set_lock_surface()

void wlmtk_root_set_lock_surface ( wlmtk_root_t * root_ptr,
wlmtk_surface_t * surface_ptr )

Temporary: Set the lock surface, so events get passed correctly.

TODO(kaese.nosp@m.r@gu.nosp@m.bbe.c.nosp@m.h): Remove the method, events should get passed via the container.

Parameters
root_ptr
surface_ptr

◆ wlmtk_root_switch_to_next_workspace()

void wlmtk_root_switch_to_next_workspace ( wlmtk_root_t * root_ptr)

Switches to the next workspace.

Parameters
root_ptr

◆ wlmtk_root_switch_to_previous_workspace()

void wlmtk_root_switch_to_previous_workspace ( wlmtk_root_t * root_ptr)

Switches to the previous workspace.

Parameters
root_ptr

◆ wlmtk_root_unlock()

bool wlmtk_root_unlock ( wlmtk_root_t * root_ptr,
wlmtk_lock_t * lock_ptr )

Unlocks the root, and releases the reference from wlmtk_root_lock.

Unlocking can only be done with lock_ptr matching the lock_ptr argument from wlmtk_root_lock.

Parameters
root_ptr
lock_ptr
Returns
Whether the lock was lifted.

Variable Documentation

◆ _wlmtk_root_element_vmt

const wlmtk_element_vmt_t _wlmtk_root_element_vmt
static
Initial value:
= {
}
static bool _wlmtk_root_element_pointer_axis(wlmtk_element_t *element_ptr, struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr)
Definition root.c:583
static bool _wlmtk_root_element_pointer_motion(wlmtk_element_t *element_ptr, double x, double y, uint32_t time_msec)
Definition root.c:514
static bool _wlmtk_root_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)
Definition root.c:620
static bool _wlmtk_root_element_pointer_button(wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr)
Definition root.c:549

Virtual method table for the container's super class: Element.

◆ wlmtk_root_test_cases

const bs_test_case_t wlmtk_root_test_cases[]
Initial value:
= {
{ 1, "create_destroy", test_create_destroy },
{ 1, "workspaces", test_workspaces },
{ 1, "pointer_button", test_pointer_button },
{ 0, NULL, NULL }
}
static void test_create_destroy(bs_test_t *test_ptr)
Definition root.c:682
static void test_pointer_button(bs_test_t *test_ptr)
Definition root.c:766
static void test_workspaces(bs_test_t *test_ptr)
Definition root.c:703

Unit test cases.