wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions | Variables
workspace.c File Reference
#include "workspace.h"
#include "fsm.h"
#include "layer.h"
#include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/util/edges.h>
Include dependency graph for workspace.c:

Classes

struct  _wlmtk_workspace_t
 
struct  _wlmtk_workspace_test_listeners_t
 

Enumerations

enum  pointer_state_t { PFSMS_PASSTHROUGH , PFSMS_MOVE , PFSMS_RESIZE }
 
enum  pointer_state_event_t {
  PFSME_BEGIN_MOVE , PFSME_BEGIN_RESIZE , PFSME_RELEASED , PFSME_MOTION ,
  PFSME_RESET
}
 

Functions

static void _wlmtk_workspace_element_destroy (wlmtk_element_t *element_ptr)
 
static void _wlmtk_workspace_element_get_dimensions (wlmtk_element_t *element_ptr, int *left_ptr, int *top_ptr, int *right_ptr, int *bottom_ptr)
 
static void _wlmtk_workspace_element_get_pointer_area (wlmtk_element_t *element_ptr, int *x1_ptr, int *y1_ptr, int *x2_ptr, int *y2_ptr)
 
static bool _wlmtk_workspace_element_pointer_motion (wlmtk_element_t *element_ptr, double x, double y, uint32_t time_msec)
 
static bool _wlmtk_workspace_element_pointer_button (wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr)
 
static void _wlmtk_workspace_element_pointer_leave (wlmtk_element_t *element_ptr)
 
static bool pfsm_move_begin (wlmtk_fsm_t *fsm_ptr, void *ud_ptr)
 
static bool pfsm_move_motion (wlmtk_fsm_t *fsm_ptr, void *ud_ptr)
 
static bool pfsm_resize_begin (wlmtk_fsm_t *fsm_ptr, void *ud_ptr)
 
static bool pfsm_resize_motion (wlmtk_fsm_t *fsm_ptr, void *ud_ptr)
 
static bool pfsm_reset (wlmtk_fsm_t *fsm_ptr, void *ud_ptr)
 
wlmtk_workspace_twlmtk_workspace_create (const char *name_ptr, const wlmtk_tile_style_t *tile_style_ptr, wlmtk_env_t *env_ptr)
 
void wlmtk_workspace_destroy (wlmtk_workspace_t *workspace_ptr)
 
void wlmtk_workspace_set_details (wlmtk_workspace_t *workspace_ptr, int index)
 
void wlmtk_workspace_get_details (wlmtk_workspace_t *workspace_ptr, const char **name_ptr_ptr, int *index_ptr)
 
void wlmtk_workspace_set_extents (wlmtk_workspace_t *workspace_ptr, const struct wlr_box *extents_ptr)
 
struct wlr_box wlmtk_workspace_get_maximize_extents (wlmtk_workspace_t *workspace_ptr)
 
struct wlr_box wlmtk_workspace_get_fullscreen_extents (wlmtk_workspace_t *workspace_ptr)
 
void wlmtk_workspace_enable (wlmtk_workspace_t *workspace_ptr, bool enabled)
 
void wlmtk_workspace_map_window (wlmtk_workspace_t *workspace_ptr, wlmtk_window_t *window_ptr)
 
void wlmtk_workspace_unmap_window (wlmtk_workspace_t *workspace_ptr, wlmtk_window_t *window_ptr)
 
wlmtk_layer_twlmtk_workspace_get_layer (wlmtk_workspace_t *workspace_ptr, wlmtk_workspace_layer_t layer)
 
bs_dllist_t * wlmtk_workspace_get_windows_dllist (wlmtk_workspace_t *workspace_ptr)
 
void wlmtk_workspace_window_to_fullscreen (wlmtk_workspace_t *workspace_ptr, wlmtk_window_t *window_ptr, bool fullscreen)
 
void wlmtk_workspace_begin_window_move (wlmtk_workspace_t *workspace_ptr, wlmtk_window_t *window_ptr)
 
void wlmtk_workspace_begin_window_resize (wlmtk_workspace_t *workspace_ptr, wlmtk_window_t *window_ptr, uint32_t edges)
 
void wlmtk_workspace_activate_window (wlmtk_workspace_t *workspace_ptr, wlmtk_window_t *window_ptr)
 
wlmtk_window_twlmtk_workspace_get_activated_window (wlmtk_workspace_t *workspace_ptr)
 
void wlmtk_workspace_activate_previous_window (wlmtk_workspace_t *workspace_ptr)
 
void wlmtk_workspace_activate_next_window (wlmtk_workspace_t *workspace_ptr)
 
void wlmtk_workspace_raise_window (wlmtk_workspace_t *workspace_ptr, wlmtk_window_t *window_ptr)
 
wlmtk_element_twlmtk_workspace_element (wlmtk_workspace_t *workspace_ptr)
 
wlmtk_root_twlmtk_workspace_get_root (wlmtk_workspace_t *workspace_ptr)
 
void wlmtk_workspace_set_root (wlmtk_workspace_t *workspace_ptr, wlmtk_root_t *root_ptr)
 
bs_dllist_node_t * wlmtk_dlnode_from_workspace (wlmtk_workspace_t *workspace_ptr)
 
wlmtk_workspace_twlmtk_workspace_from_dlnode (bs_dllist_node_t *dlnode_ptr)
 
wlmtk_workspace_twlmtk_workspace_create_for_test (int width, int height, wlmtk_env_t *env_ptr)
 
static void test_create_destroy (bs_test_t *test_ptr)
 
static void test_map_unmap (bs_test_t *test_ptr)
 
static void test_move (bs_test_t *test_ptr)
 
static void test_unmap_during_move (bs_test_t *test_ptr)
 
static void test_resize (bs_test_t *test_ptr)
 
static void test_enable (bs_test_t *test_ptr)
 
static void test_activate (bs_test_t *test_ptr)
 
static void test_activate_cycling (bs_test_t *test_ptr)
 
static void _wlmtk_workspace_test_handle_window_mapped (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmtk_workspace_test_handle_window_unmapped (struct wl_listener *listener_ptr, void *data_ptr)
 

Variables

const wlmtk_element_vmt_t workspace_element_vmt
 
static const wlmtk_fsm_transition_t pfsm_transitions []
 
const bs_test_case_t wlmtk_workspace_test_cases []
 
static const wlmtk_tile_style_t _wlmtk_workspace_test_tile_style
 

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.

Enumeration Type Documentation

◆ pointer_state_event_t

Events for the pointer FSM.

◆ pointer_state_t

States of the pointer FSM.

Function Documentation

◆ _wlmtk_workspace_element_destroy()

void _wlmtk_workspace_element_destroy ( wlmtk_element_t * element_ptr)
static

Virtual destructor, wraps to our dtor.

◆ _wlmtk_workspace_element_get_dimensions()

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

Returns the workspace area.

◆ _wlmtk_workspace_element_get_pointer_area()

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

Returns workspace area: _wlmtk_workspace_element_get_dimensions.

◆ _wlmtk_workspace_element_pointer_button()

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

Extends wlmtk_container_t::pointer_button.

Parameters
element_ptr
button_event_ptr
Returns
Whether the button event was consumed.

◆ _wlmtk_workspace_element_pointer_leave()

void _wlmtk_workspace_element_pointer_leave ( wlmtk_element_t * element_ptr)
static

Extends wlmtk_container_t::leave.

Parameters
element_ptr

◆ _wlmtk_workspace_element_pointer_motion()

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

Extends wlmtk_container_t::pointer_button: Feeds the motion into the workspace's pointer state machine, and only passes it to the container's handler if the event isn't consumed yet.

Parameters
element_ptr
x
y
time_msec
Returns
Always true.

◆ _wlmtk_workspace_test_handle_window_mapped()

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

◆ _wlmtk_workspace_test_handle_window_unmapped()

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

◆ pfsm_move_begin()

bool pfsm_move_begin ( wlmtk_fsm_t * fsm_ptr,
void * ud_ptr )
static

Initiates a move.

◆ pfsm_move_motion()

bool pfsm_move_motion ( wlmtk_fsm_t * fsm_ptr,
void * ud_ptr )
static

Handles motion during a move.

◆ pfsm_reset()

bool pfsm_reset ( wlmtk_fsm_t * fsm_ptr,
void * ud_ptr )
static

Resets the state machine.

◆ pfsm_resize_begin()

bool pfsm_resize_begin ( wlmtk_fsm_t * fsm_ptr,
void * ud_ptr )
static

Initiates a resize.

◆ pfsm_resize_motion()

bool pfsm_resize_motion ( wlmtk_fsm_t * fsm_ptr,
void * ud_ptr )
static

Handles motion during a resize.

◆ test_activate()

void test_activate ( bs_test_t * test_ptr)
static

Tests window activation.

◆ test_activate_cycling()

void test_activate_cycling ( bs_test_t * test_ptr)
static

Tests cycling through windows.

◆ test_create_destroy()

void test_create_destroy ( bs_test_t * test_ptr)
static

Exercises workspace create & destroy methods.

◆ test_enable()

void test_enable ( bs_test_t * test_ptr)
static

Tests enabling or disabling the workspace.

◆ test_map_unmap()

void test_map_unmap ( bs_test_t * test_ptr)
static

Verifies that mapping and unmapping windows works.

◆ test_move()

void test_move ( bs_test_t * test_ptr)
static

Tests moving a window.

◆ test_resize()

void test_resize ( bs_test_t * test_ptr)
static

Tests resizing a window.

◆ test_unmap_during_move()

void test_unmap_during_move ( bs_test_t * test_ptr)
static

Tests moving a window that unmaps during the move.

◆ wlmtk_dlnode_from_workspace()

bs_dllist_node_t * wlmtk_dlnode_from_workspace ( wlmtk_workspace_t * workspace_ptr)
Returns
Pointer to wlmtk_workspace_t::dlnode.

◆ wlmtk_workspace_activate_next_window()

void wlmtk_workspace_activate_next_window ( wlmtk_workspace_t * workspace_ptr)

Activates the wlmtk_window_t after the currently activated one.

Intended to permit cycling through tasks. Will activate the window, but not raise it. See wlmtk_workspace_activate_previous_window.

Parameters
workspace_ptr

◆ wlmtk_workspace_activate_previous_window()

void wlmtk_workspace_activate_previous_window ( wlmtk_workspace_t * workspace_ptr)

Activates the wlmtk_window_t before the currently activated one.

Intended to permit cycling through tasks. Will activate the window, but not raise it. See wlmtk_workspace_activate_next_window.

Parameters
workspace_ptr

◆ wlmtk_workspace_activate_window()

void wlmtk_workspace_activate_window ( wlmtk_workspace_t * workspace_ptr,
wlmtk_window_t * window_ptr )

Acticates window_ptr. Will de-activate an earlier window.

◆ wlmtk_workspace_begin_window_move()

void wlmtk_workspace_begin_window_move ( wlmtk_workspace_t * workspace_ptr,
wlmtk_window_t * window_ptr )

Initiates a 'move' for the window.

Parameters
workspace_ptr
window_ptr

◆ wlmtk_workspace_begin_window_resize()

void wlmtk_workspace_begin_window_resize ( wlmtk_workspace_t * workspace_ptr,
wlmtk_window_t * window_ptr,
uint32_t edges )

Initiates a 'resize' for the window.

Parameters
workspace_ptr
window_ptr
edges

◆ wlmtk_workspace_create()

wlmtk_workspace_t * wlmtk_workspace_create ( const char * name_ptr,
const wlmtk_tile_style_t * tile_style_ptr,
wlmtk_env_t * env_ptr )

Creates a workspace.

Parameters
name_ptr
tile_style_ptr
env_ptr
Returns
Pointer to the workspace state, or NULL on error. Must be free'd via wlmtk_workspace_destroy.

◆ wlmtk_workspace_create_for_test()

wlmtk_workspace_t * wlmtk_workspace_create_for_test ( int width,
int height,
wlmtk_env_t * env_ptr )

Creates a workspace with defined extents, suitably for tests.

Parameters
width
height
env_ptr
Returns
A pointer to a wlmtk_workspace_t or NULL on error.

◆ wlmtk_workspace_destroy()

void wlmtk_workspace_destroy ( wlmtk_workspace_t * workspace_ptr)

Destroys the workspace. Will destroy any stil-contained element.

Parameters
workspace_ptr

◆ wlmtk_workspace_element()

wlmtk_element_t * wlmtk_workspace_element ( wlmtk_workspace_t * workspace_ptr)
Returns
Pointer to wlmtk_workspace_t::super_container::super_element.

◆ wlmtk_workspace_enable()

void wlmtk_workspace_enable ( wlmtk_workspace_t * workspace_ptr,
bool enabled )

Enabled or disables the workspace.

An enabled workspace can have keyboard focus and activated windows. When re-enabling a workspace, the formerly activated window will get re-activated and re-gains keyboard focus.

Parameters
workspace_ptr
enabled

◆ wlmtk_workspace_from_dlnode()

wlmtk_workspace_t * wlmtk_workspace_from_dlnode ( bs_dllist_node_t * dlnode_ptr)
Returns
Poitner to the wlmtk_workspace_t of the dlnode_ptr.

◆ wlmtk_workspace_get_activated_window()

wlmtk_window_t * wlmtk_workspace_get_activated_window ( wlmtk_workspace_t * workspace_ptr)
Returns
Pointer to the activated wlmtk_window_t, if any.

◆ wlmtk_workspace_get_details()

void wlmtk_workspace_get_details ( wlmtk_workspace_t * workspace_ptr,
const char ** name_ptr_ptr,
int * index_ptr )

Retrieves the naming details of this workspace.

Parameters
workspace_ptr
name_ptr_ptr
index_ptr

◆ wlmtk_workspace_get_fullscreen_extents()

struct wlr_box wlmtk_workspace_get_fullscreen_extents ( wlmtk_workspace_t * workspace_ptr)

Returns the extents of the workspace available for fullscreen windows.

Parameters
workspace_ptr
Returns
A struct wlr_box that lines out the available space and position.

◆ wlmtk_workspace_get_layer()

wlmtk_layer_t * wlmtk_workspace_get_layer ( wlmtk_workspace_t * workspace_ptr,
wlmtk_workspace_layer_t layer )

Returns pointer to the wlmtk_layer_t handle serving layer.

Parameters
workspace_ptr
layer
Returns
Pointer to the layer state.

◆ wlmtk_workspace_get_maximize_extents()

struct wlr_box wlmtk_workspace_get_maximize_extents ( wlmtk_workspace_t * workspace_ptr)

Returns the extents of the workspace available for maximized windows.

Parameters
workspace_ptr
Returns
A struct wlr_box that lines out the available space and position.

◆ wlmtk_workspace_get_root()

wlmtk_root_t * wlmtk_workspace_get_root ( wlmtk_workspace_t * workspace_ptr)
Returns
pointer to the anchor wlmtk_root_t of workspace_ptr.

◆ wlmtk_workspace_get_windows_dllist()

bs_dllist_t * wlmtk_workspace_get_windows_dllist ( wlmtk_workspace_t * workspace_ptr)

Returns the bs_dllist_t of currently mapped windows.

Parameters
workspace_ptr
Returns
A pointer to the list. Note that the list should not be manipulated directly. It's contents can change on wlmtk_workspace_map_window or wlmtk_workspace_unmap_window calls.

◆ wlmtk_workspace_map_window()

void wlmtk_workspace_map_window ( wlmtk_workspace_t * workspace_ptr,
wlmtk_window_t * window_ptr )

Maps the window: Adds it to the workspace container and makes it visible.

Parameters
workspace_ptr
window_ptr

◆ wlmtk_workspace_raise_window()

void wlmtk_workspace_raise_window ( wlmtk_workspace_t * workspace_ptr,
wlmtk_window_t * window_ptr )

Raises window_ptr: Will show it atop all other windows.

◆ wlmtk_workspace_set_details()

void wlmtk_workspace_set_details ( wlmtk_workspace_t * workspace_ptr,
int index )

Sets or updates workspace details.

Parameters
workspace_ptr
index

◆ wlmtk_workspace_set_extents()

void wlmtk_workspace_set_extents ( wlmtk_workspace_t * workspace_ptr,
const struct wlr_box * extents_ptr )

Sets (or updates) the extents of the workspace.

Parameters
workspace_ptr
extents_ptr

◆ wlmtk_workspace_set_root()

void wlmtk_workspace_set_root ( wlmtk_workspace_t * workspace_ptr,
wlmtk_root_t * root_ptr )

Sets the anchor wlmtk_root_t of workspace_ptr.

Must only be called from wlmtk_root_t.

Parameters
workspace_ptr
root_ptr

◆ wlmtk_workspace_unmap_window()

void wlmtk_workspace_unmap_window ( wlmtk_workspace_t * workspace_ptr,
wlmtk_window_t * window_ptr )

Unmaps the window: Sets it as invisible and removes it from the container.

Parameters
workspace_ptr
window_ptr

◆ wlmtk_workspace_window_to_fullscreen()

void wlmtk_workspace_window_to_fullscreen ( wlmtk_workspace_t * workspace_ptr,
wlmtk_window_t * window_ptr,
bool fullscreen )

Promotes the window to the fullscreen layer (or back).

To be called by wlmtk_window_commit_fullscreen.

Parameters
workspace_ptr
window_ptr
fullscreen

Variable Documentation

◆ _wlmtk_workspace_test_tile_style

const wlmtk_tile_style_t _wlmtk_workspace_test_tile_style
static
Initial value:
= {
.size = 64
}

Tile style used in tests.

◆ pfsm_transitions

const wlmtk_fsm_transition_t pfsm_transitions[]
static
Initial value:
= {
{ PFSMS_PASSTHROUGH, PFSME_BEGIN_MOVE, PFSMS_MOVE, pfsm_move_begin },
{ PFSMS_MOVE, PFSME_MOTION, PFSMS_MOVE, pfsm_move_motion },
{ PFSMS_MOVE, PFSME_RELEASED, PFSMS_PASSTHROUGH, pfsm_reset },
{ PFSMS_MOVE, PFSME_RESET, PFSMS_PASSTHROUGH, pfsm_reset },
{ PFSMS_PASSTHROUGH, PFSME_BEGIN_RESIZE, PFSMS_RESIZE, pfsm_resize_begin },
{ PFSMS_RESIZE, PFSME_MOTION, PFSMS_RESIZE, pfsm_resize_motion },
{ PFSMS_RESIZE, PFSME_RELEASED, PFSMS_PASSTHROUGH, pfsm_reset },
{ PFSMS_RESIZE, PFSME_RESET, PFSMS_PASSTHROUGH, pfsm_reset },
}
#define WLMTK_FSM_TRANSITION_SENTINEL
Definition fsm.h:56
static bool pfsm_move_begin(wlmtk_fsm_t *fsm_ptr, void *ud_ptr)
Definition workspace.c:871
static bool pfsm_resize_begin(wlmtk_fsm_t *fsm_ptr, void *ud_ptr)
Definition workspace.c:914
static bool pfsm_move_motion(wlmtk_fsm_t *fsm_ptr, void *ud_ptr)
Definition workspace.c:894
static bool pfsm_reset(wlmtk_fsm_t *fsm_ptr, void *ud_ptr)
Definition workspace.c:980
static bool pfsm_resize_motion(wlmtk_fsm_t *fsm_ptr, void *ud_ptr)
Definition workspace.c:940

Finite state machine definition for pointer events.

◆ wlmtk_workspace_test_cases

const bs_test_case_t wlmtk_workspace_test_cases[]
Initial value:
= {
{ 1, "create_destroy", test_create_destroy },
{ 1, "map_unmap", test_map_unmap },
{ 1, "move", test_move },
{ 1, "unmap_during_move", test_unmap_during_move },
{ 1, "resize", test_resize },
{ 1, "enable", test_enable } ,
{ 1, "activate", test_activate },
{ 1, "activate_cycling", test_activate_cycling },
{ 0, NULL, NULL }
}
static void test_move(bs_test_t *test_ptr)
Definition workspace.c:1161
static void test_resize(bs_test_t *test_ptr)
Definition workspace.c:1250
static void test_create_destroy(bs_test_t *test_ptr)
Definition workspace.c:1054
static void test_map_unmap(bs_test_t *test_ptr)
Definition workspace.c:1094
static void test_unmap_during_move(bs_test_t *test_ptr)
Definition workspace.c:1207
static void test_activate(bs_test_t *test_ptr)
Definition workspace.c:1362
static void test_enable(bs_test_t *test_ptr)
Definition workspace.c:1305
static void test_activate_cycling(bs_test_t *test_ptr)
Definition workspace.c:1448

Unit tests for the workspace.

◆ workspace_element_vmt

const wlmtk_element_vmt_t workspace_element_vmt
Initial value:
= {
}
static bool _wlmtk_workspace_element_pointer_motion(wlmtk_element_t *element_ptr, double x, double y, uint32_t time_msec)
Definition workspace.c:802
static void _wlmtk_workspace_element_destroy(wlmtk_element_t *element_ptr)
Definition workspace.c:751
static void _wlmtk_workspace_element_get_pointer_area(wlmtk_element_t *element_ptr, int *x1_ptr, int *y1_ptr, int *x2_ptr, int *y2_ptr)
Definition workspace.c:778
static void _wlmtk_workspace_element_pointer_leave(wlmtk_element_t *element_ptr)
Definition workspace.c:860
static void _wlmtk_workspace_element_get_dimensions(wlmtk_element_t *element_ptr, int *left_ptr, int *top_ptr, int *right_ptr, int *bottom_ptr)
Definition workspace.c:760
static bool _wlmtk_workspace_element_pointer_button(wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr)
Definition workspace.c:834

Extensions to the workspace's super element's virtual methods.