wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
lock_mgr.c File Reference
#include "lock_mgr.h"
#include <libbase/libbase.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <wayland-server-core.h>
#include <wayland-server-protocol.h>
#include <wayland-util.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_session_lock_v1.h>
#include <wlr/util/box.h>
#include "toolkit/toolkit.h"
Include dependency graph for lock_mgr.c:

Classes

struct  _wlmaker_lock_mgr_t
 
struct  _wlmaker_lock_t
 
struct  _wlmaker_lock_surface_t
 
struct  wlmaker_lock_update_output_arg_t
 

Typedefs

typedef uint32_t(* _wlmaker_lock_surface_configure_t) (struct wlr_session_lock_surface_v1 *lock_surface, uint32_t width, uint32_t height)
 
typedef void(* _wlmaker_lock_send_locked_t) (struct wlr_session_lock_v1 *lock)
 
typedef struct _wlmaker_lock_t wlmaker_lock_t
 
typedef struct _wlmaker_lock_surface_t wlmaker_lock_surface_t
 

Functions

static void _wlmaker_lock_mgr_handle_new_lock (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmaker_lock_mgr_handle_destroy (struct wl_listener *listener_ptr, void *data_ptr)
 
static wlmaker_lock_t_wlmaker_lock_create (struct wlr_session_lock_v1 *wlr_session_lock_v1_ptr, struct wlr_output_layout *wlr_output_layout_ptr, struct wlr_seat *wlr_seat_ptr, wlmtk_root_t *root_ptr, _wlmaker_lock_surface_configure_t injected_surface_configure, _wlmaker_lock_send_locked_t injected_send_locked)
 
static void _wlmaker_lock_destroy (wlmaker_lock_t *lock_ptr)
 
static wlmtk_element_t_wlmaker_lock_element (wlmaker_lock_t *lock_ptr)
 
static void _wlmaker_lock_register_lock_surface (wlmaker_lock_t *lock_ptr, wlmaker_lock_surface_t *lock_surface_ptr)
 
static void _wlmaker_lock_handle_new_surface (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmaker_lock_handle_unlock (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmaker_lock_handle_destroy (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmaker_lock_handle_output_layout_change (struct wl_listener *listener_ptr, void *data_ptr)
 
static bool _wlmaker_lock_update_output (struct wl_list *link_ptr, void *ud_ptr)
 
static wlmaker_lock_surface_t_wlmaker_lock_surface_create (struct wlr_session_lock_surface_v1 *wlr_session_lock_surface_v1_ptr, wlmaker_lock_t *lock_ptr)
 
static void _wlmaker_lock_surface_destroy (wlmaker_lock_surface_t *lock_surface_ptr)
 
static void _wlmaker_lock_surface_handle_destroy (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmaker_lock_surface_handle_surface_commit (struct wl_listener *listener_ptr, void *data_ptr)
 
static int _wlmaker_lock_surface_avlnode_cmp (const bs_avltree_node_t *node_ptr, const void *key_ptr)
 
static void _wlmaker_lock_surface_avlnode_destroy (bs_avltree_node_t *node_ptr)
 
wlmaker_lock_mgr_twlmaker_lock_mgr_create (wlmaker_server_t *server_ptr)
 
void wlmaker_lock_mgr_destroy (wlmaker_lock_mgr_t *lock_mgr_ptr)
 
static void test_lock_unlock (bs_test_t *test_ptr)
 
static void test_lock_crash (bs_test_t *test_ptr)
 
static void test_lock_multi_output (bs_test_t *test_ptr)
 
static uint32_t _mock_wlr_session_lock_surface_v1_configure (struct wlr_session_lock_surface_v1 *lock_surface, uint32_t width, uint32_t height)
 
static void _mock_wlr_session_lock_v1_send_locked (struct wlr_session_lock_v1 *lock)
 
static void _init_test_session_lock (struct wlr_session_lock_v1 *wlr_session_lock_v1_ptr)
 
static void _init_test_surface (struct wlr_surface *wlr_surface_ptr)
 

Variables

const bs_test_case_t wlmaker_lock_mgr_test_cases []
 
static uint32_t _mock_configure_serial
 
static uint32_t _mock_configure_width
 
static uint32_t _mock_configure_height
 
static struct wlr_session_lock_surface_v1 * _mock_configure_lock_surface
 
static struct wlr_session_lock_v1 * _mock_send_locked_lock
 

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

◆ _wlmaker_lock_send_locked_t

typedef void(* _wlmaker_lock_send_locked_t) (struct wlr_session_lock_v1 *lock)

Type of wlr_session_lock_v1_send_locked().

◆ _wlmaker_lock_surface_configure_t

typedef uint32_t(* _wlmaker_lock_surface_configure_t) (struct wlr_session_lock_surface_v1 *lock_surface, uint32_t width, uint32_t height)

Type of wlr_session_lock_surface_v1_configure().

◆ wlmaker_lock_surface_t

Forward declaration: Lock surface.

◆ wlmaker_lock_t

Forward declaration: Lock.

Function Documentation

◆ _init_test_session_lock()

void _init_test_session_lock ( struct wlr_session_lock_v1 *  wlr_session_lock_v1_ptr)
static

Initializes the minimum required attributes of the session lock.

◆ _init_test_surface()

void _init_test_surface ( struct wlr_surface *  wlr_surface_ptr)
static

Initializes the minimum required attributes of the wlr_surface.

◆ _mock_wlr_session_lock_surface_v1_configure()

uint32_t _mock_wlr_session_lock_surface_v1_configure ( struct wlr_session_lock_surface_v1 *  lock_surface,
uint32_t  width,
uint32_t  height 
)
static

Mock for configure().

◆ _mock_wlr_session_lock_v1_send_locked()

void _mock_wlr_session_lock_v1_send_locked ( struct wlr_session_lock_v1 *  lock)
static

Mock for send_locked().

◆ _wlmaker_lock_create()

wlmaker_lock_t * _wlmaker_lock_create ( struct wlr_session_lock_v1 *  wlr_session_lock_v1_ptr,
struct wlr_output_layout *  wlr_output_layout_ptr,
struct wlr_seat *  wlr_seat_ptr,
wlmtk_root_t root_ptr,
_wlmaker_lock_surface_configure_t  injected_surface_configure,
_wlmaker_lock_send_locked_t  injected_send_locked 
)
static

Creates a session lock handle.

Parameters
wlr_session_lock_v1_ptr
wlr_output_layout_ptr
wlr_seat_ptr
root_ptr
injected_surface_configure
injected_send_locked
Returns
The lock handle or NULL on error.

◆ _wlmaker_lock_destroy()

void _wlmaker_lock_destroy ( wlmaker_lock_t lock_ptr)
static

Destroys the session lock handle.

Parameters
lock_ptr

◆ _wlmaker_lock_element()

wlmtk_element_t * _wlmaker_lock_element ( wlmaker_lock_t lock_ptr)
static

◆ _wlmaker_lock_handle_destroy()

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

Handler for the destroy signal of wlr_session_lock_v1: Destroy the lock.

Parameters
listener_ptr
data_ptr

◆ _wlmaker_lock_handle_new_surface()

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

Handler for the new_surface signal of wlr_session_lock_v1: Creates the associated surface and enables it on the screenlock container.

Parameters
listener_ptr
data_ptr

◆ _wlmaker_lock_handle_output_layout_change()

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

Handles the change event of wlr_output_layout::events.

Walks through outputs of wlmaker_lock_t::wlr_output_layout_ptr, and updates wlmaker_lock_t::lock_surface_tree_ptr accordingly.

Parameters
listener_ptr
data_ptr

◆ _wlmaker_lock_handle_unlock()

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

Handler for the unlock signal of wlr_session_lock_v1: Marks the session as unlocked.

Parameters
listener_ptr
data_ptr

◆ _wlmaker_lock_mgr_handle_destroy()

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

Handler for the destroy signal of wlr_session_lock_manager_v1: Cleans up associated resources.

Parameters
listener_ptr
data_ptr

◆ _wlmaker_lock_mgr_handle_new_lock()

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

Handler for the new_lock signal of wlr_session_lock_manager_v1: creates the corresponding lock.

Parameters
listener_ptr
data_ptr

◆ _wlmaker_lock_register_lock_surface()

void _wlmaker_lock_register_lock_surface ( wlmaker_lock_t lock_ptr,
wlmaker_lock_surface_t lock_surface_ptr 
)
static

Registers the provided surface as a lock surface for it's output, unless it had already been registered. Locks the session, once lock surfaces for all surfaces have been registered.

Parameters
lock_ptr
lock_surface_ptr

◆ _wlmaker_lock_surface_avlnode_cmp()

int _wlmaker_lock_surface_avlnode_cmp ( const bs_avltree_node_t *  avlnode_ptr,
const void *  key_ptr 
)
static

Comparator for wlmaker_lock_t::lock_surface_tree_ptr by output.

◆ _wlmaker_lock_surface_avlnode_destroy()

void _wlmaker_lock_surface_avlnode_destroy ( bs_avltree_node_t *  avlnode_ptr)
static

◆ _wlmaker_lock_surface_create()

wlmaker_lock_surface_t * _wlmaker_lock_surface_create ( struct wlr_session_lock_surface_v1 *  wlr_session_lock_surface_v1_ptr,
wlmaker_lock_t lock_ptr 
)
static

Creates a lock surface.

Parameters
wlr_session_lock_surface_v1_ptr
lock_ptr
Returns
The lock surface or NULL on error.

◆ _wlmaker_lock_surface_destroy()

void _wlmaker_lock_surface_destroy ( wlmaker_lock_surface_t lock_surface_ptr)
static

Destroys the lock surface.

Parameters
lock_surface_ptr

◆ _wlmaker_lock_surface_handle_destroy()

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

Handler for the destroy signal of wlr_session_lock_surface_v1: Destroy the surface.

Parameters
listener_ptr
data_ptr

◆ _wlmaker_lock_surface_handle_surface_commit()

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

Handler for the commit signal of wlr_session_lock_surface_v1::surface.

Checks whether the serial is at-or-above the 'configure' serial, and reports the surface and output as locked. Once all surfaces are locked, a 'send_locked' event will be sent.

Parameters
listener_ptr
data_ptr

◆ _wlmaker_lock_update_output()

bool _wlmaker_lock_update_output ( struct wl_list *  link_ptr,
void *  ud_ptr 
)
static

Updates the lock surfaces for an output: If there is a surface for the output, moves it into the new surface tree, and sends a configure() event with new dimensions. Otherwise, a no-op.

Parameters
link_ptr
ud_ptrA wlmaker_lock_update_output_arg_t.
Returns
true if the operation succeeded. It may fail if there's multiple surface per output; although that would be indicative of data corruption.

◆ test_lock_crash()

void test_lock_crash ( bs_test_t *  test_ptr)
static

Tests locking, and then the session lock going away: Must remain locked.

◆ test_lock_multi_output()

void test_lock_multi_output ( bs_test_t *  test_ptr)
static

Tests locking with multiple outputs. Lock only when all outputs covered.

◆ test_lock_unlock()

void test_lock_unlock ( bs_test_t *  test_ptr)
static

Tests locking & unlocking, proper sequence, single output.

◆ wlmaker_lock_mgr_create()

wlmaker_lock_mgr_t * wlmaker_lock_mgr_create ( wlmaker_server_t server_ptr)

Creates the session lock manager.

Parameters
server_ptr
Returns
The session lock manager handler or NULL on error.

◆ wlmaker_lock_mgr_destroy()

void wlmaker_lock_mgr_destroy ( wlmaker_lock_mgr_t lock_mgr_ptr)

Destroys the session lock manager.

Parameters
lock_mgr_ptr

Variable Documentation

◆ _mock_configure_height

uint32_t _mock_configure_height
static

◆ _mock_configure_lock_surface

struct wlr_session_lock_surface_v1* _mock_configure_lock_surface
static

◆ _mock_configure_serial

uint32_t _mock_configure_serial
static

◆ _mock_configure_width

uint32_t _mock_configure_width
static

◆ _mock_send_locked_lock

struct wlr_session_lock_v1* _mock_send_locked_lock
static

◆ wlmaker_lock_mgr_test_cases

const bs_test_case_t wlmaker_lock_mgr_test_cases[]
Initial value:
= {
{ 1, "lock_unlock", test_lock_unlock },
{ 1, "lock_crash", test_lock_crash },
{ 1, "lock_multi_output", test_lock_multi_output },
{ 0, NULL, NULL }
}
static void test_lock_crash(bs_test_t *test_ptr)
Definition lock_mgr.c:975
static void test_lock_multi_output(bs_test_t *test_ptr)
Definition lock_mgr.c:1046
static void test_lock_unlock(bs_test_t *test_ptr)
Definition lock_mgr.c:896

Unit test cases for wlmaker_lock_mgr_t.