wlmaker
Loading...
Searching...
No Matches
Macros | Functions | Variables
content.c File Reference
#include "content.h"
#include <stdlib.h>
#include <wlr/types/wlr_compositor.h>
#include "input.h"
#include "surface.h"
#include "window.h"
Include dependency graph for content.c:

Functions

static void _wlmtk_content_element_get_dimensions (wlmtk_element_t *element_ptr, int *left_ptr, int *top_ptr, int *right_ptr, int *bottom_ptr)
 
static void _wlmtk_content_element_keyboard_blur (wlmtk_element_t *element_ptr)
 
bool wlmtk_content_init (wlmtk_content_t *content_ptr, wlmtk_element_t *element_ptr)
 
void wlmtk_content_fini (wlmtk_content_t *content_ptr)
 
void wlmtk_content_set_element (wlmtk_content_t *content_ptr, wlmtk_element_t *element_ptr)
 
wlmtk_content_vmt_t wlmtk_content_extend (wlmtk_content_t *content_ptr, const wlmtk_content_vmt_t *content_vmt_ptr)
 
void wlmtk_content_get_size (wlmtk_content_t *content_ptr, int *width_ptr, int *height_ptr)
 
void wlmtk_content_commit (wlmtk_content_t *content_ptr, int width, int height, uint32_t serial)
 
void wlmtk_content_set_window (wlmtk_content_t *content_ptr, wlmtk_window_t *window_ptr)
 
wlmtk_element_twlmtk_content_element (wlmtk_content_t *content_ptr)
 
void wlmtk_content_add_popup (wlmtk_content_t *content_ptr, wlmtk_content_t *popup_content_ptr)
 
void wlmtk_content_remove_popup (wlmtk_content_t *content_ptr, wlmtk_content_t *popup_content_ptr)
 
void wlmtk_content_add_wlmtk_popup (wlmtk_content_t *content_ptr, wlmtk_popup_t *popup_ptr)
 
void wlmtk_content_remove_wlmtk_popup (wlmtk_content_t *content_ptr, wlmtk_popup_t *popup_ptr)
 
wlmtk_content_twlmtk_content_get_parent_content (wlmtk_content_t *content_ptr)
 
static void _wlmtk_fake_content_request_close (wlmtk_content_t *content_ptr)
 
static uint32_t _wlmtk_fake_content_request_size (wlmtk_content_t *content_ptr, int width, int height)
 
static void _wlmtk_fake_content_set_activated (wlmtk_content_t *content_ptr, bool activated)
 
wlmtk_fake_content_twlmtk_fake_content_create (wlmtk_fake_surface_t *fake_surface_ptr)
 
void wlmtk_fake_content_destroy (wlmtk_fake_content_t *fake_content_ptr)
 
void wlmtk_fake_content_commit (wlmtk_fake_content_t *fake_content_ptr)
 
static void test_init_fini (bs_test_t *test_ptr)
 
static void test_set_clear_element (bs_test_t *test_ptr)
 
static void test_add_remove_popup (bs_test_t *test_ptr)
 
static void test_add_remove_wlmtk_popup (bs_test_t *test_ptr)
 

Variables

static const wlmtk_element_vmt_t _wlmtk_content_element_vmt
 
static wlmtk_content_vmt_t _wlmtk_fake_content_vmt
 
const bs_test_case_t wlmtk_content_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_content_element_get_dimensions()

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

Returns the content's dimension: Considers only the element, and leaves out pop-ups, in order to draw margins and decorations for just the main element.

Parameters
element_ptr
left_ptr
top_ptr
right_ptr
bottom_ptr

◆ _wlmtk_content_element_keyboard_blur()

void _wlmtk_content_element_keyboard_blur ( wlmtk_element_t element_ptr)
static

De-activates keyboard focus for the content: Propagates the blur to all children, and then de-activates the content's window.

Parameters
element_ptr

◆ _wlmtk_fake_content_request_close()

void _wlmtk_fake_content_request_close ( wlmtk_content_t content_ptr)
static

Test implementation of wlmtk_content_vmt_t::request_close.

◆ _wlmtk_fake_content_request_size()

uint32_t _wlmtk_fake_content_request_size ( wlmtk_content_t content_ptr,
int  width,
int  height 
)
static

Test implementation of wlmtk_content_vmt_t::request_size.

◆ _wlmtk_fake_content_set_activated()

void _wlmtk_fake_content_set_activated ( wlmtk_content_t content_ptr,
bool  activated 
)
static

Test implementation of wlmtk_content_vmt_t::set_activated.

◆ test_add_remove_popup()

void test_add_remove_popup ( bs_test_t *  test_ptr)
static

Tests adding and removing popups.

◆ test_add_remove_wlmtk_popup()

void test_add_remove_wlmtk_popup ( bs_test_t *  test_ptr)
static

Tests adding and removing popups.

◆ test_init_fini()

void test_init_fini ( bs_test_t *  test_ptr)
static

Tests setup and teardown.

◆ test_set_clear_element()

void test_set_clear_element ( bs_test_t *  test_ptr)
static

Tests setting and clearing the element.

◆ wlmtk_content_add_popup()

void wlmtk_content_add_popup ( wlmtk_content_t content_ptr,
wlmtk_content_t popup_content_ptr 
)

Adds a popup to the content.

Parameters
content_ptr
popup_content_ptr

◆ wlmtk_content_add_wlmtk_popup()

void wlmtk_content_add_wlmtk_popup ( wlmtk_content_t content_ptr,
wlmtk_popup_t popup_ptr 
)

Adds a popup to the content.

Parameters
content_ptr
popup_ptr

◆ wlmtk_content_commit()

void wlmtk_content_commit ( wlmtk_content_t content_ptr,
int  width,
int  height,
uint32_t  serial 
)

Commits size and serial: Calls into wlmtk_window_serial.

◆ wlmtk_content_element()

wlmtk_element_t * wlmtk_content_element ( wlmtk_content_t content_ptr)

Returns the superclass' instance of wlmtk_element_t.

◆ wlmtk_content_extend()

wlmtk_content_vmt_t wlmtk_content_extend ( wlmtk_content_t content_ptr,
const wlmtk_content_vmt_t content_vmt_ptr 
)

Extends the content by specifying virtual methods.

Parameters
content_ptr
content_vmt_ptr
Returns
The original virtual method table.

◆ wlmtk_content_fini()

void wlmtk_content_fini ( wlmtk_content_t content_ptr)

Un-initializes the content.

Parameters
content_ptr

◆ wlmtk_content_get_parent_content()

wlmtk_content_t * wlmtk_content_get_parent_content ( wlmtk_content_t content_ptr)
Returns
A pointer to the parent content, or NULL if none.

◆ wlmtk_content_get_size()

void wlmtk_content_get_size ( wlmtk_content_t content_ptr,
int *  width_ptr,
int *  height_ptr 
)

Gets size: Returns size from earlier wlmtk_content_commit.

◆ wlmtk_content_init()

bool wlmtk_content_init ( wlmtk_content_t content_ptr,
wlmtk_element_t element_ptr 
)

Initializes the content with the given element.

Parameters
content_ptr
element_ptr
Returns
true on success.

◆ wlmtk_content_remove_popup()

void wlmtk_content_remove_popup ( wlmtk_content_t content_ptr,
wlmtk_content_t popup_content_ptr 
)

Removes a popup from the content.

popup_content_ptr must have previously been added to content_ptr.

Parameters
content_ptr
popup_content_ptr

◆ wlmtk_content_remove_wlmtk_popup()

void wlmtk_content_remove_wlmtk_popup ( wlmtk_content_t content_ptr,
wlmtk_popup_t popup_ptr 
)

Removes a popup from the content.

popup_ptr must have previously been added to content_ptr.

Parameters
content_ptr
popup_ptr

◆ wlmtk_content_set_element()

void wlmtk_content_set_element ( wlmtk_content_t content_ptr,
wlmtk_element_t element_ptr 
)

Sets or clears the content's element.

Parameters
content_ptr
element_ptrElement to set for the content, or NULL.

◆ wlmtk_content_set_window()

void wlmtk_content_set_window ( wlmtk_content_t content_ptr,
wlmtk_window_t window_ptr 
)

Sets the window for the content.

Private: Should only be called by Window ctor (a friend).

Parameters
content_ptr
window_ptr

◆ wlmtk_fake_content_commit()

void wlmtk_fake_content_commit ( wlmtk_fake_content_t fake_content_ptr)

Commits the state of last wlmtk_content_request_size call.

◆ wlmtk_fake_content_create()

wlmtk_fake_content_t * wlmtk_fake_content_create ( wlmtk_fake_surface_t fake_surface_ptr)

Creates a fake content, for tests.

◆ wlmtk_fake_content_destroy()

void wlmtk_fake_content_destroy ( wlmtk_fake_content_t fake_content_ptr)

Destroys the fake content.

Variable Documentation

◆ _wlmtk_content_element_vmt

const wlmtk_element_vmt_t _wlmtk_content_element_vmt
static
Initial value:
= {
}
static void _wlmtk_content_element_keyboard_blur(wlmtk_element_t *element_ptr)
Definition content.c:307
static void _wlmtk_content_element_get_dimensions(wlmtk_element_t *element_ptr, int *left_ptr, int *top_ptr, int *right_ptr, int *bottom_ptr)
Definition content.c:285

Virtual method table for the content's superclass wlmtk_element_t.

◆ _wlmtk_fake_content_vmt

wlmtk_content_vmt_t _wlmtk_fake_content_vmt
static
Initial value:
= {
}
static void _wlmtk_fake_content_request_close(wlmtk_content_t *content_ptr)
Definition content.c:390
static void _wlmtk_fake_content_set_activated(wlmtk_content_t *content_ptr, bool activated)
Definition content.c:399
static uint32_t _wlmtk_fake_content_request_size(wlmtk_content_t *content_ptr, int width, int height)
Definition content.c:376

Virtual method table for the fake content.

◆ wlmtk_content_test_cases

const bs_test_case_t wlmtk_content_test_cases[]
Initial value:
= {
{ 1, "init_fini", test_init_fini },
{ 1, "set_clear_element", test_set_clear_element },
{ 1, "add_remove_popup", test_add_remove_popup },
{ 1, "add_remove_wlmtk_popup", test_add_remove_wlmtk_popup },
{ 0, NULL, NULL }
}
static void test_add_remove_popup(bs_test_t *test_ptr)
Definition content.c:496
static void test_set_clear_element(bs_test_t *test_ptr)
Definition content.c:470
static void test_add_remove_wlmtk_popup(bs_test_t *test_ptr)
Definition content.c:555
static void test_init_fini(bs_test_t *test_ptr)
Definition content.c:425

Content's unit tests.