Compare commits

...

12 commits

Author SHA1 Message Date
Johan Malm
60d536304b Privatize view_append_children() 2025-09-29 20:22:46 +01:00
Johan Malm
9ec49144ac Privatize desktop_topmost_focusable_view() 2025-09-29 20:22:46 +01:00
Johan Malm
eb41c6a3b0 Privatize view_contains_window_type() 2025-09-29 20:22:46 +01:00
Johan Malm
2ea0f6fff4 Privatize output_manager_init() 2025-09-29 20:22:46 +01:00
Johan Malm
950c634cea Privatize xwayland_surface_from_view() 2025-09-29 20:22:46 +01:00
Johan Malm
286005e121 Privatize rcxml_parse_xml() 2025-09-29 20:22:46 +01:00
Johan Malm
040e25f38e Privatize private view_get_root() 2025-09-29 20:22:46 +01:00
Johan Malm
27f3097f8f build: add 'sections' option to show unused functions 2025-09-29 20:22:46 +01:00
tokyo4j
c5cd1f691d CI: use libwlroots-0.19-dev build-dep for Debian 2025-09-29 19:41:32 +01:00
tokyo4j
46bd1fef95 CI: add unit tests 2025-09-29 19:41:32 +01:00
tokyo4j
7e27f78662 test/xml: use xmlBufferContent()
xmlBuffer->content has been deprecated.
2025-09-29 19:41:32 +01:00
tokyo4j
1043a9becc test: fix build error in t/xml.c
38a1a9b broke `t/xml.c` due to `macros.h` requiring `wlr/version.h`.
This commit fixes it by adding `wlroots` as a direct dependency of the
test executables.
2025-09-29 19:41:32 +01:00
15 changed files with 84 additions and 66 deletions

View file

@ -82,7 +82,7 @@ jobs:
pacman -Syu --noconfirm
pacman -S --noconfirm git meson clang wlroots0.19 libdrm libinput \
wayland-protocols cairo pango libxml2 xorg-xwayland librsvg \
libdisplay-info gdb ttf-dejavu foot libsfdo
libdisplay-info gdb ttf-dejavu foot libsfdo cmocka
- name: Install Debian Testing dependencies
if: matrix.name == 'Debian'
@ -92,7 +92,7 @@ jobs:
apt-get upgrade -y
apt-get install -y git gcc clang gdb xwayland
apt-get build-dep -y labwc
apt-get build-dep -y libwlroots-0.18-dev
apt-get build-dep -y libwlroots-0.19-dev
- name: Install FreeBSD dependencies
if: matrix.name == 'FreeBSD'
@ -207,6 +207,18 @@ jobs:
meson compile -C build-gcc-no-feature
' | $TARGET
# Unit tests, run on Arch only
- name: Build with gcc - unit test
if: matrix.name == 'Arch'
run: |
echo '
cd "$GITHUB_WORKSPACE"
export CC=gcc
meson setup build-gcc-unit-test -Dtest=enabled --werror
meson compile -C build-gcc-unit-test
meson test -C build-gcc-unit-test --print-errorlogs
' | $TARGET
# Runtime tests, these run on Arch and Void only (the later due to libmusl being used)
- name: Build with gcc - runtime test
if: matrix.name == 'Arch'

View file

@ -200,7 +200,6 @@ struct rcxml {
extern struct rcxml rc;
void rcxml_parse_xml(struct buf *b);
void rcxml_read(const char *filename);
void rcxml_finish(void);

View file

@ -359,7 +359,6 @@ void desktop_focus_view_or_surface(struct seat *seat, struct view *view,
void desktop_arrange_all_views(struct server *server);
void desktop_focus_output(struct output *output);
struct view *desktop_topmost_focusable_view(struct server *server);
/**
* Toggles the (output local) visibility of the layershell top layer

View file

@ -40,7 +40,6 @@ struct output {
void output_init(struct server *server);
void output_finish(struct server *server);
void output_manager_init(struct server *server);
struct output *output_from_wlr_output(struct server *server,
struct wlr_output *wlr_output);
struct output *output_from_name(struct server *server, const char *name);

View file

@ -425,7 +425,6 @@ void view_array_append(struct server *server, struct wl_array *views,
enum lab_view_criteria criteria);
enum view_wants_focus view_wants_focus(struct view *view);
bool view_contains_window_type(struct view *view, enum lab_window_type window_type);
/* If view is NULL, the size of SSD is not considered */
struct wlr_box view_get_edge_snap_box(struct view *view, struct output *output,
@ -554,8 +553,6 @@ void view_move_to_output(struct view *view, struct output *output);
void view_move_to_front(struct view *view);
void view_move_to_back(struct view *view);
struct view *view_get_root(struct view *view);
void view_append_children(struct view *view, struct wl_array *children);
/**
* view_get_modal_dialog() - returns any modal dialog found among this

View file

@ -65,8 +65,6 @@ void xwayland_unmanaged_create(struct server *server,
void xwayland_view_create(struct server *server,
struct wlr_xwayland_surface *xsurface, bool mapped);
struct wlr_xwayland_surface *xwayland_surface_from_view(struct view *view);
void xwayland_server_init(struct server *server,
struct wlr_compositor *compositor);
void xwayland_server_finish(struct server *server);

View file

@ -134,6 +134,15 @@ if get_option('static_analyzer').enabled()
add_project_arguments(['-fanalyzer'], language: 'c')
endif
link_args = []
if get_option('sections').enabled()
add_project_arguments(['-ffunction-sections'], language: 'c')
link_args += [
'-Wl,--gc-sections',
'-Wl,--print-gc-sections',
]
endif
msgfmt = find_program('msgfmt', required: get_option('nls'))
if msgfmt.found()
source_root = meson.current_source_dir()
@ -193,6 +202,7 @@ executable(
include_directories: [labwc_inc],
dependencies: labwc_deps,
install: true,
link_args: link_args,
)
install_data('data/labwc.desktop', install_dir: get_option('datadir') / 'wayland-sessions')

View file

@ -5,3 +5,4 @@ option('icon', type: 'feature', value: 'enabled', description: 'Enable window ic
option('nls', type: 'feature', value: 'auto', description: 'Enable native language support')
option('static_analyzer', type: 'feature', value: 'disabled', description: 'Run gcc static analyzer')
option('test', type: 'feature', value: 'disabled', description: 'Run tests')
option('sections', type: 'feature', value: 'disabled', description: 'Show unused functions')

View file

@ -1323,8 +1323,7 @@ traverse(xmlNode *node)
}
}
/* Exposed in header file to allow unit tests to parse buffers */
void
static void
rcxml_parse_xml(struct buf *b)
{
int options = 0;

View file

@ -132,7 +132,7 @@ desktop_focus_view_or_surface(struct seat *seat, struct view *view,
}
}
struct view *
static struct view *
desktop_topmost_focusable_view(struct server *server)
{
struct view *view;

View file

@ -551,6 +551,8 @@ handle_new_output(struct wl_listener *listener, void *data)
do_output_layout_change(server);
}
static void output_manager_init(struct server *server);
void
output_init(struct server *server)
{
@ -890,7 +892,7 @@ handle_gamma_control_set_gamma(struct wl_listener *listener, void *data)
wlr_output_schedule_frame(output->wlr_output);
}
void
static void
output_manager_init(struct server *server)
{
server->output_manager = wlr_output_manager_v1_create(server->wl_display);

View file

@ -120,6 +120,16 @@ query_str_match(const char *condition, const char *value)
return value && match_glob(condition, value);
}
static bool
view_contains_window_type(struct view *view, enum lab_window_type window_type)
{
assert(view);
if (view->impl->contains_window_type) {
return view->impl->contains_window_type(view, window_type);
}
return false;
}
bool
view_matches_query(struct view *view, struct view_query *query)
{
@ -240,6 +250,16 @@ view_matches_query(struct view *view, struct view_query *query)
return true;
}
static struct view *
view_get_root(struct view *view)
{
assert(view);
if (view->impl->get_root) {
return view->impl->get_root(view);
}
return view;
}
static bool
matches_criteria(struct view *view, enum lab_view_criteria criteria)
{
@ -393,16 +413,6 @@ view_wants_focus(struct view *view)
return VIEW_WANTS_FOCUS_ALWAYS;
}
bool
view_contains_window_type(struct view *view, enum lab_window_type window_type)
{
assert(view);
if (view->impl->contains_window_type) {
return view->impl->contains_window_type(view, window_type);
}
return false;
}
bool
view_is_focusable(struct view *view)
{
@ -798,6 +808,15 @@ _minimize(struct view *view, bool minimized)
}
}
static void
view_append_children(struct view *view, struct wl_array *children)
{
assert(view);
if (view->impl->append_children) {
view->impl->append_children(view, children);
}
}
static void
minimize_sub_views(struct view *view, bool minimized)
{
@ -2327,25 +2346,6 @@ view_move_to_back(struct view *view)
desktop_update_top_layer_visibility(view->server);
}
struct view *
view_get_root(struct view *view)
{
assert(view);
if (view->impl->get_root) {
return view->impl->get_root(view);
}
return view;
}
void
view_append_children(struct view *view, struct wl_array *children)
{
assert(view);
if (view->impl->append_children) {
view->impl->append_children(view, children);
}
}
struct view *
view_get_modal_dialog(struct view *view)
{

View file

@ -40,6 +40,21 @@ static xcb_atom_t atoms[ATOM_COUNT] = {0};
static void xwayland_view_unmap(struct view *view, bool client_request);
static struct xwayland_view *
xwayland_view_from_view(struct view *view)
{
assert(view->type == LAB_XWAYLAND_VIEW);
return (struct xwayland_view *)view;
}
static struct wlr_xwayland_surface *
xwayland_surface_from_view(struct view *view)
{
struct xwayland_view *xwayland_view = xwayland_view_from_view(view);
assert(xwayland_view->xwayland_surface);
return xwayland_view->xwayland_surface;
}
static bool
xwayland_view_contains_window_type(struct view *view,
enum lab_window_type window_type)
@ -186,21 +201,6 @@ top_parent_of(struct view *view)
return s;
}
static struct xwayland_view *
xwayland_view_from_view(struct view *view)
{
assert(view->type == LAB_XWAYLAND_VIEW);
return (struct xwayland_view *)view;
}
struct wlr_xwayland_surface *
xwayland_surface_from_view(struct view *view)
{
struct xwayland_view *xwayland_view = xwayland_view_from_view(view);
assert(xwayland_view->xwayland_surface);
return xwayland_view->xwayland_surface;
}
static void
ensure_initial_geometry_and_output(struct view *view)
{

View file

@ -1,3 +1,10 @@
test_deps = [
dep_cmocka,
glib,
xml2,
wlroots,
]
test_lib = static_library(
'test_lib',
sources: files(
@ -8,12 +15,7 @@ test_lib = static_library(
'../src/common/parse-bool.c',
),
include_directories: [labwc_inc],
dependencies: [
dep_cmocka,
glib,
xml2,
wlroots,
],
dependencies: test_deps,
)
tests = [
@ -30,7 +32,7 @@ foreach t : tests
sources: '@0@.c'.format(t),
include_directories: [labwc_inc],
link_with: [test_lib],
dependencies: [xml2],
dependencies: test_deps,
),
is_parallel: false,
)

View file

@ -111,7 +111,7 @@ test_lab_xml_expand_dotted_attributes(void **state)
xmlBuffer *buf = xmlBufferCreate();
xmlNodeDump(buf, root->doc, root, 0, 0);
assert_string_equal(test_cases[i].after, (char *)buf->content);
assert_string_equal(test_cases[i].after, (char *)xmlBufferContent(buf));
xmlBufferFree(buf);
xmlFreeDoc(doc);