wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
desktop.c File Reference
#include "desktop.h"
#include <libbase/libbase.h>
#include <stdlib.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_scene.h>
#include "container.h"
#include "input.h"
#include "rectangle.h"
#include "test.h"
#include "tile.h"
#include "util.h"
#include "window.h"
#include "workspace.h"
Include dependency graph for desktop.c:

Classes

struct  _wlmtk_desktop_t
 
struct  _wlmtk_desktop_set_style_arg
 

Functions

static void _wlmtk_desktop_switch_to_workspace (wlmtk_desktop_t *desktop_ptr, wlmtk_workspace_t *workspace_ptr)
 
static void _wlmtk_desktop_enumerate_workspaces (bs_dllist_node_t *dlnode_ptr, void *ud_ptr)
 
static void _wlmtk_desktop_destroy_workspace (bs_dllist_node_t *dlnode_ptr, void *ud_ptr)
 
static bool _wlmtk_desktop_element_pointer_button (wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr)
 
static bool _wlmtk_desktop_element_pointer_axis (wlmtk_element_t *element_ptr, struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr)
 
static bool _wlmtk_desktop_element_keyboard_event (wlmtk_element_t *element_ptr, struct wlr_keyboard_key_event *wlr_keyboard_key_event_ptr)
 
static void _wlmtk_desktop_handle_output_layout_change (struct wl_listener *listener_ptr, void *data_ptr)
 
static bool _wlmtk_desktop_window_set_style (bs_dllist_node_t *dlnode_ptr, void *ud_ptr)
 
static bool _wlmtk_desktop_workspace_set_style (bs_dllist_node_t *dlnode_ptr, void *ud_ptr)
 
wlmtk_desktop_twlmtk_desktop_create (struct wlr_scene *wlr_scene_ptr, struct wlr_output_layout *wlr_output_layout_ptr)
 
void wlmtk_desktop_destroy (wlmtk_desktop_t *desktop_ptr)
 
wlmtk_desktop_events_twlmtk_desktop_events (wlmtk_desktop_t *desktop_ptr)
 
void wlmtk_desktop_add_workspace (wlmtk_desktop_t *desktop_ptr, wlmtk_workspace_t *workspace_ptr)
 
void wlmtk_desktop_remove_workspace (wlmtk_desktop_t *desktop_ptr, wlmtk_workspace_t *workspace_ptr)
 
wlmtk_workspace_twlmtk_desktop_get_current_workspace (wlmtk_desktop_t *desktop_ptr)
 
void wlmtk_desktop_destroy_last_workspace (wlmtk_desktop_t *desktop_ptr)
 
void wlmtk_desktop_switch_to_next_workspace (wlmtk_desktop_t *desktop_ptr)
 
void wlmtk_desktop_switch_to_previous_workspace (wlmtk_desktop_t *desktop_ptr)
 
void wlmtk_desktop_for_each_workspace (wlmtk_desktop_t *desktop_ptr, void(*func)(bs_dllist_node_t *dlnode_ptr, void *ud_ptr), void *ud_ptr)
 
bool wlmtk_desktop_lock (wlmtk_desktop_t *desktop_ptr, wlmtk_element_t *element_ptr)
 
bool wlmtk_desktop_unlock (wlmtk_desktop_t *desktop_ptr, wlmtk_element_t *element_ptr)
 
bool wlmtk_desktop_locked (wlmtk_desktop_t *desktop_ptr)
 
void wlmtk_desktop_lock_unreference (wlmtk_desktop_t *desktop_ptr, wlmtk_element_t *element_ptr)
 
wlmtk_element_twlmtk_desktop_element (wlmtk_desktop_t *desktop_ptr)
 
bool wlmtk_desktop_set_style (wlmtk_desktop_t *desktop_ptr, wlmtk_window_style_ref_t *window_style_ref_ptr, wlmtk_menu_style_ref_t *menu_style_ref_ptr)
 
static void test_create_destroy (bs_test_t *test_ptr)
 
static void test_workspaces (bs_test_t *test_ptr)
 

Variables

static const wlmtk_element_vmt_t _wlmtk_desktop_element_vmt
 
static const bs_test_case_t _wlmtk_desktop_test_cases []
 
const bs_test_set_t wlmtk_desktop_test_set
 

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_desktop_destroy_workspace()

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

Callback for bs_dllist_for_each: Destroys the workspace.

◆ _wlmtk_desktop_element_keyboard_event()

bool _wlmtk_desktop_element_keyboard_event ( wlmtk_element_t element_ptr,
struct wlr_keyboard_key_event *  wlr_keyboard_key_event_ptr 
)
static

Implements wlmtk_element_vmt_t::keyboard_event. Handle keyboard events.

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

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

◆ _wlmtk_desktop_element_pointer_axis()

bool _wlmtk_desktop_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 desktop 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_desktop_element_pointer_button()

bool _wlmtk_desktop_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 desktop 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_desktop_enumerate_workspaces()

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

Callback for bs_dllist_for_each: Enumerates the workspace.

◆ _wlmtk_desktop_handle_output_layout_change()

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

Handles wlr_output_layout::events::change. Triggers when the output layout changes, and we use this for updating the curtain and the layout in each workspace.

Parameters
listener_ptr
data_ptr

◆ _wlmtk_desktop_switch_to_workspace()

void _wlmtk_desktop_switch_to_workspace ( wlmtk_desktop_t desktop_ptr,
wlmtk_workspace_t workspace_ptr 
)
static

Switches to workspace_ptr as the current workspace.

Parameters
desktop_ptr
workspace_ptr

◆ _wlmtk_desktop_window_set_style()

bool _wlmtk_desktop_window_set_style ( bs_dllist_node_t *  dlnode_ptr,
void *  ud_ptr 
)
static

Calls wlmtk_window_set_style for the window at dlnode_ptr.

◆ _wlmtk_desktop_workspace_set_style()

bool _wlmtk_desktop_workspace_set_style ( bs_dllist_node_t *  dlnode_ptr,
void *  ud_ptr 
)
static

Sets the style for each window of the workspace.

◆ test_create_destroy()

void test_create_destroy ( bs_test_t *  test_ptr)
static

Exercises ctor and dtor.

◆ test_workspaces()

void test_workspaces ( bs_test_t *  test_ptr)
static

Exercises workspace adding and removal.

◆ wlmtk_desktop_add_workspace()

void wlmtk_desktop_add_workspace ( wlmtk_desktop_t desktop_ptr,
wlmtk_workspace_t workspace_ptr 
)

Adds a workspace.

Parameters
desktop_ptr
workspace_ptr

◆ wlmtk_desktop_create()

wlmtk_desktop_t * wlmtk_desktop_create ( struct wlr_scene *  wlr_scene_ptr,
struct wlr_output_layout *  wlr_output_layout_ptr 
)

Creates the desktop element.

Parameters
wlr_scene_ptr
wlr_output_layout_ptr
Returns
Handle of the desktop element or NULL on error.

◆ wlmtk_desktop_destroy()

void wlmtk_desktop_destroy ( wlmtk_desktop_t desktop_ptr)

Destroys the desktop element.

Parameters
desktop_ptr

◆ wlmtk_desktop_destroy_last_workspace()

void wlmtk_desktop_destroy_last_workspace ( wlmtk_desktop_t desktop_ptr)

Destroys the last workspace – if it's not the only remaining workspace, not the current workspace, and if there's no windows contained in it.

Parameters
desktop_ptr

◆ wlmtk_desktop_element()

wlmtk_element_t * wlmtk_desktop_element ( wlmtk_desktop_t desktop_ptr)
Returns
pointer to the desktop's wlmtk_element_t. (Temporary)

◆ wlmtk_desktop_events()

wlmtk_desktop_events_t * wlmtk_desktop_events ( wlmtk_desktop_t desktop_ptr)

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

Parameters
desktop_ptr
Returns
Pointer to wlmtk_desktop_t::events.

◆ wlmtk_desktop_for_each_workspace()

void wlmtk_desktop_for_each_workspace ( wlmtk_desktop_t desktop_ptr,
void(*)(bs_dllist_node_t *dlnode_ptr, void *ud_ptr)  func,
void *  ud_ptr 
)

Runs |func()| for each workspace.

Parameters
desktop_ptr
func
ud_ptr

◆ wlmtk_desktop_get_current_workspace()

wlmtk_workspace_t * wlmtk_desktop_get_current_workspace ( wlmtk_desktop_t desktop_ptr)

Returns a pointer to the currently-active workspace.

Parameters
desktop_ptr

◆ wlmtk_desktop_lock()

bool wlmtk_desktop_lock ( wlmtk_desktop_t desktop_ptr,
wlmtk_element_t element_ptr 
)

Locks the desktop, using the provided element.

The desktop must not be locked already. If locked successfully, the desktop will keep a reference to element_ptr. The lock must call wlmtk_desktop_unlock to unlock desktop, and for releasing the reference.

Parameters
desktop_ptr
element_ptr
Returns
Whether the lock was established.

◆ wlmtk_desktop_lock_unreference()

void wlmtk_desktop_lock_unreference ( wlmtk_desktop_t desktop_ptr,
wlmtk_element_t element_ptr 
)

Releases the lock reference, but keeps the desktop 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 element_ptr is not currently the lock of desktop_ptr.

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

Parameters
desktop_ptr
element_ptr

◆ wlmtk_desktop_locked()

bool wlmtk_desktop_locked ( wlmtk_desktop_t desktop_ptr)
Returns
Whether desktop is locked.

◆ wlmtk_desktop_remove_workspace()

void wlmtk_desktop_remove_workspace ( wlmtk_desktop_t desktop_ptr,
wlmtk_workspace_t workspace_ptr 
)

Removes the workspace.

Parameters
desktop_ptr
workspace_ptr

◆ wlmtk_desktop_set_style()

bool wlmtk_desktop_set_style ( wlmtk_desktop_t desktop_ptr,
wlmtk_window_style_ref_t window_style_ref_ptr,
wlmtk_menu_style_ref_t menu_style_ref_ptr 
)

Updates the style for all windows contained in desktop.

◆ wlmtk_desktop_switch_to_next_workspace()

void wlmtk_desktop_switch_to_next_workspace ( wlmtk_desktop_t desktop_ptr)

Switches to the next workspace.

Parameters
desktop_ptr

◆ wlmtk_desktop_switch_to_previous_workspace()

void wlmtk_desktop_switch_to_previous_workspace ( wlmtk_desktop_t desktop_ptr)

Switches to the previous workspace.

Parameters
desktop_ptr

◆ wlmtk_desktop_unlock()

bool wlmtk_desktop_unlock ( wlmtk_desktop_t desktop_ptr,
wlmtk_element_t element_ptr 
)

Unlocks the desktop, and releases the reference from wlmtk_desktop_lock.

Unlocking can only be done with element_ptr matching the element_ptr argument from wlmtk_desktop_lock.

Parameters
desktop_ptr
element_ptr
Returns
Whether the lock was lifted.

Variable Documentation

◆ _wlmtk_desktop_element_vmt

const wlmtk_element_vmt_t _wlmtk_desktop_element_vmt
static
Initial value:
= {
}
static bool _wlmtk_desktop_element_pointer_axis(wlmtk_element_t *element_ptr, struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr)
Definition desktop.c:540
static bool _wlmtk_desktop_element_keyboard_event(wlmtk_element_t *element_ptr, struct wlr_keyboard_key_event *wlr_keyboard_key_event_ptr)
Definition desktop.c:574
static bool _wlmtk_desktop_element_pointer_button(wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr)
Definition desktop.c:506

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

◆ _wlmtk_desktop_test_cases

const bs_test_case_t _wlmtk_desktop_test_cases[]
static
Initial value:
= {
{ 1, "create_destroy", test_create_destroy },
{ 1, "workspaces", test_workspaces },
}
static void test_create_destroy(bs_test_t *test_ptr)
Definition desktop.c:673
static void test_workspaces(bs_test_t *test_ptr)
Definition desktop.c:696

Test cases

◆ wlmtk_desktop_test_set

const bs_test_set_t wlmtk_desktop_test_set
Initial value:
= BS_TEST_SET(
true, "desktop", _wlmtk_desktop_test_cases)
static const bs_test_case_t _wlmtk_desktop_test_cases[]
Definition desktop.c:662

Unit test cases.