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
5 changed files with 30 additions and 26 deletions

View File

@ -28,6 +28,4 @@ test:
dependencies: dependencies:
- build_meson - build_meson
script: script:
- export LC_ALL=C.UTF-8 - xvfb-run -s -noreset ninja -C _build test
- ninja -C _build test

5
debian/control vendored
View File

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

View File

@ -147,12 +147,11 @@ create_keyboard_surface_section_callback (EekElement *element,
cairo_restore (data->cr); cairo_restore (data->cr);
} }
static cairo_surface_t * void
create_keyboard_surface (EekRenderer *renderer) render_keyboard_surface (EekRenderer *renderer)
{ {
EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer); EekRendererPrivate *priv = eek_renderer_get_instance_private (renderer);
EekBounds bounds; EekBounds bounds;
cairo_surface_t *keyboard_surface;
CreateKeyboardSurfaceCallbackData data; CreateKeyboardSurfaceCallbackData data;
EekColor foreground, background; EekColor foreground, background;
@ -165,14 +164,7 @@ create_keyboard_surface (EekRenderer *renderer)
eek_element_get_bounds (EEK_ELEMENT(priv->keyboard), &bounds); eek_element_get_bounds (EEK_ELEMENT(priv->keyboard), &bounds);
/* Create a surface that encompasses the dimensions of the keyboard as well data.cr = cairo_create (priv->keyboard_surface);
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.renderer = renderer; data.renderer = renderer;
cairo_translate (data.cr, bounds.x * priv->scale, bounds.y * priv->scale); 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, create_keyboard_surface_section_callback,
&data); &data);
cairo_destroy (data.cr); cairo_destroy (data.cr);
return keyboard_surface;
} }
static void 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_width > 0.0);
g_return_if_fail (priv->allocation_height > 0.0); g_return_if_fail (priv->allocation_height > 0.0);
if (!priv->keyboard_surface) if (priv->keyboard_surface)
priv->keyboard_surface = create_keyboard_surface (self); 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); cairo_set_source_surface (cr, priv->keyboard_surface, 0.0, 0.0);
source = cairo_get_source (cr); source = cairo_get_source (cr);

View File

@ -89,6 +89,7 @@ libsqueekboard = static_library('libsqueekboard',
squeekboard = executable('squeekboard', squeekboard = executable('squeekboard',
'server-main.c', 'server-main.c',
wl_proto_sources, wl_proto_sources,
squeekboard_resources,
link_with: libsqueekboard, link_with: libsqueekboard,
include_directories: [include_directories('..'), include_directories('../eek')], include_directories: [include_directories('..'), include_directories('../eek')],
dependencies: deps, dependencies: deps,

View File

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