Compare commits

...

12 Commits

Author SHA1 Message Date
99a7786dc3 Remove declaration of unused variable 2019-07-26 12:01:04 +02:00
e9cf572a3c Only recreate the widget when the keyboard layout changes
Avoid creating a widget before there is a window to put it in.
2019-07-25 18:07:29 +00:00
1246776328 Create the keyboard surface every time it is needed
Icons are still blurry the first time the keyboard is shown after
rotation.
2019-07-24 14:04:28 +00:00
ea15f69e73 Render the keyboard to a subsurface of the widget 2019-07-24 13:12:57 +00:00
2e22bb5431 Merge branch 'fix-squeekboard-resources' into 'master'
Ensure that resources are built with the application

See merge request Librem5/squeekboard!95
2019-07-23 23:25:33 +00:00
a9a6e1d2b5 Ensure that resources are built with the application 2019-07-24 01:22:58 +02:00
4b66add65f Merge branch 'ci' into 'master'
Run tests in ci

See merge request Librem5/squeekboard!94
2019-07-23 11:29:34 +00:00
79dce7c4c3 gitlab-ci: Run tests under xvfb
We create widgets so need a display.
2019-07-23 10:20:07 +02:00
aff71e0e33 debian: Add test run dependencies
We need xvfb to run the tests since this involves creating GTK
widgets.
2019-07-23 10:20:02 +02:00
9b10f56ba6 Keep the build directory as an artifact 2019-07-23 10:18:44 +02:00
2391947b34 Update CI configuration to enable tests 2019-07-23 10:18:44 +02:00
e903150971 Enable tests, fixing the existing ones to use the current API
This also involved building a static library for the application for
tests to link to. The main application executable also links to it.
2019-07-23 10:18:44 +02:00
10 changed files with 132 additions and 36 deletions

View File

@ -2,16 +2,30 @@ image: debian:buster
stages:
- build
- test
.tags: &tags
tags:
- librem5
before_script:
- apt-get -y update
- apt-get -y build-dep .
build_meson:
<<: *tags
stage: build
tags:
- librem5
artifacts:
paths:
- _build
script:
- meson . _build/ -Ddepdatadir=/usr/share
- ninja -C _build install
test:
<<: *tags
stage: test
dependencies:
- build_meson
script:
- xvfb-run -s -noreset ninja -C _build test

5
debian/control vendored
View File

@ -11,7 +11,10 @@ Build-Depends:
libcroco3-dev,
libwayland-dev (>= 1.16),
rustc,
wayland-protocols (>= 1.14)
wayland-protocols (>= 1.14),
# for running the tests
xvfb,
xauth,
Standards-Version: 4.1.3
Homepage: https://source.puri.sm/Librem5/squeekboard

View File

@ -147,12 +147,11 @@ create_keyboard_surface_section_callback (EekElement *element,
cairo_restore (data->cr);
}
static cairo_surface_t *
create_keyboard_surface (EekRenderer *renderer)
void
render_keyboard_surface (EekRenderer *renderer)
{
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
EekBounds bounds;
cairo_surface_t *keyboard_surface;
CreateKeyboardSurfaceCallbackData data;
EekColor foreground, background;
@ -165,14 +164,7 @@ create_keyboard_surface (EekRenderer *renderer)
eek_element_get_bounds (EEK_ELEMENT(priv->keyboard), &bounds);
/* Create a surface that encompasses the dimensions of the keyboard as well
as the margin around the edge. */
keyboard_surface = cairo_image_surface_create (
CAIRO_FORMAT_ARGB32,
ceil(((bounds.x * 2) + bounds.width) * priv->scale),
ceil(((bounds.y * 2) + bounds.height) * priv->scale));
data.cr = cairo_create (keyboard_surface);
data.cr = cairo_create (priv->keyboard_surface);
data.renderer = renderer;
cairo_translate (data.cr, bounds.x * priv->scale, bounds.y * priv->scale);
@ -196,8 +188,6 @@ create_keyboard_surface (EekRenderer *renderer)
create_keyboard_surface_section_callback,
&data);
cairo_destroy (data.cr);
return keyboard_surface;
}
static void
@ -706,8 +696,14 @@ eek_renderer_real_render_keyboard (EekRenderer *self,
g_return_if_fail (priv->allocation_width > 0.0);
g_return_if_fail (priv->allocation_height > 0.0);
if (!priv->keyboard_surface)
priv->keyboard_surface = create_keyboard_surface (self);
if (priv->keyboard_surface)
cairo_surface_destroy (priv->keyboard_surface);
priv->keyboard_surface = cairo_surface_create_for_rectangle (
cairo_get_target (cr), 0, 0,
priv->allocation_width, priv->allocation_height);
render_keyboard_surface (self);
cairo_set_source_surface (cr, priv->keyboard_surface, 0.0, 0.0);
source = cairo_get_source (cr);

View File

@ -4,7 +4,11 @@ project(
version: '1.0.10',
license: 'GPLv3',
meson_version: '>=0.49.0',
default_options: [ 'warning_level=1', 'buildtype=debugoptimized', 'c_std=gnu11' ],
default_options: [
'warning_level=1',
'buildtype=debugoptimized',
'c_std=gnu11'
]
)
i18n = import('i18n')
@ -43,3 +47,4 @@ subdir('protocols')
subdir('eek')
subdir('src')
subdir('po')
subdir('tests')

View File

@ -1 +1,8 @@
option('depdatadir', type : 'string', value : '', description : 'System data path. Will be searched for definitions instead of datadir when provided')
option('depdatadir',
type : 'string',
value : '',
description : 'System data path. Will be searched for definitions instead of datadir when provided')
option('tests',
type: 'boolean', value: true,
description: 'Whether to compile unit tests')

View File

@ -4,13 +4,16 @@ dbus_src = gnome.gdbus_codegen(
join_paths(meson.source_root() / 'data' / 'dbus', 'sm.puri.OSK0.xml')
)
config_h = configure_file(input: 'config.h.in', output: 'config.h',configuration: conf_data)
config_h = configure_file(
input: 'config.h.in',
output: 'config.h',
configuration: conf_data
)
sources = [
config_h,
'imservice.c',
'server-context-service.c',
'server-main.c',
'wayland.c',
'../eek/eek.c',
'../eek/eek-container.c',
@ -71,11 +74,25 @@ rslib = static_library(
rust_crate_type: 'staticlib'
)
squeekboard = executable('squeekboard',
libsqueekboard = static_library('libsqueekboard',
sources,
link_with: rslib,
include_directories: [include_directories('..'), include_directories('../eek')],
dependencies: deps,
c_args: [
'-DTHEMESDIR="' + pkgdatadir + '/themes"',
'-DKEYBOARDSDIR="' + pkgdatadir + '/keyboards"',
'-DEEKBOARD_COMPILATION=1',
'-DEEK_COMPILATION=1'],
)
squeekboard = executable('squeekboard',
'server-main.c',
wl_proto_sources,
squeekboard_resources,
link_with: libsqueekboard,
include_directories: [include_directories('..'), include_directories('../eek')],
dependencies: deps,
install: true,
c_args: [
'-DTHEMESDIR="' + pkgdatadir + '/themes"',
@ -83,4 +100,3 @@ squeekboard = executable('squeekboard',
'-DEEKBOARD_COMPILATION=1',
'-DEEK_COMPILATION=1'],
)

View File

@ -75,6 +75,9 @@ on_destroy (GtkWidget *widget, gpointer user_data)
eekboard_context_service_destroy (EEKBOARD_CONTEXT_SERVICE (context));
}
static void
make_widget (ServerContextService *context);
static void
on_notify_keyboard (GObject *object,
GParamSpec *spec,
@ -94,6 +97,9 @@ on_notify_keyboard (GObject *object,
keyboard);
/* Recreate the keyboard widget to keep in sync with the keymap. */
if (context->window)
make_widget(context);
gboolean visible;
g_object_get (context, "visible", &visible, NULL);
@ -232,7 +238,11 @@ make_widget (ServerContextService *context)
EekKeyboard *keyboard;
EekTheme *theme;
g_return_if_fail (!context->widget);
if (context->widget) {
gtk_widget_destroy(context->widget);
context->widget = NULL;
}
theme = eek_theme_new ("resource:///sm/puri/squeekboard/style.css",
NULL,
NULL);
@ -257,12 +267,8 @@ server_context_service_real_show_keyboard (EekboardContextService *_context)
if (!context->window)
make_window (context);
if (context->widget) {
gtk_widget_destroy(context->widget);
context->widget = NULL;
}
make_widget (context);
if (!context->widget)
make_widget (context);
EEKBOARD_CONTEXT_SERVICE_CLASS (server_context_service_parent_class)->
show_keyboard (_context);

View File

@ -30,16 +30,15 @@ test_create (void)
section = eek_keyboard_create_section (keyboard);
g_assert (EEK_IS_SECTION(section));
eek_section_add_row (section, 2, EEK_ORIENTATION_HORIZONTAL);
key0 = eek_section_create_key (section, 1, 0, 0);
key0 = eek_section_create_key (section, "key0", 1, 0, 0);
g_assert (EEK_IS_KEY(key0));
key1 = eek_section_create_key (section, 2, 1, 0);
key1 = eek_section_create_key (section, "key1", 2, 1, 0);
g_assert (EEK_IS_KEY(key1));
}
int
main (int argc, char **argv)
{
g_type_init ();
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/eek-simple-test/create", test_create);
return g_test_run ();

View File

@ -36,7 +36,9 @@ test_output_parse (void)
layout = eek_xml_layout_new ("us", &error);
g_assert_no_error (error);
keyboard = eek_keyboard_new (layout, 640, 480);
/* We don't need the context service to parse an XML file, so we can pass
NULL when creating a keyboard. */
keyboard = eek_keyboard_new (NULL, layout, 640, 480);
g_object_unref (layout);
g_object_unref (keyboard);
}
@ -44,7 +46,6 @@ test_output_parse (void)
int
main (int argc, char **argv)
{
g_type_init ();
g_test_init (&argc, &argv, NULL);
gtk_init (&argc, &argv); /* for gdk_x11_display_get_xdisplay() */

49
tests/meson.build Normal file
View File

@ -0,0 +1,49 @@
if get_option('tests')
test_env = [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
'G_DEBUG=gc-friendly,fatal-warnings',
'GSETTINGS_BACKEND=memory',
'MALLOC_CHECK_=2'
]
test_cflags = [
'-I@0@/../src'.format(meson.current_source_dir()),
'-I@0@/../src'.format(meson.current_build_dir()),
'-DEEK_COMPILATION',
'-DEEKBOARD_COMPILATION'
]
test_link_args = [
'-fPIC',
]
tests = [
'eek-simple-test',
'eek-xml-test'
]
foreach name : tests
test_sources = [name + '.c']
t = executable(
name,
test_sources,
squeekboard_resources,
link_with: libsqueekboard,
c_args : test_cflags,
link_args: test_link_args,
dependencies: deps, # from src/meson.build
include_directories: [
include_directories('..'),
include_directories('../eek')
]
)
test(name, t, env: test_env)
endforeach
endif