diff options
author | Manuel Bachmann <manuel.bachmann@open.eurogiciel.org> | 2014-12-05 01:28:04 +0100 |
---|---|---|
committer | Manuel Bachmann <manuel.bachmann@open.eurogiciel.org> | 2014-12-05 01:28:04 +0100 |
commit | 9a7c6c79a8cbde7c8c0be274834328011cacbd7d (patch) | |
tree | b92aea61a1145121f9047f6e48a2be6a38611f01 | |
parent | 9d65c22f3814f85b6365dd81a5768dcff0bf60a2 (diff) | |
download | weston-common-9a7c6c79a8cbde7c8c0be274834328011cacbd7d.tar.gz weston-common-9a7c6c79a8cbde7c8c0be274834328011cacbd7d.tar.bz2 weston-common-9a7c6c79a8cbde7c8c0be274834328011cacbd7d.zip |
Add a QA client and plugin
We add a new "qa-plugin" package, which contains a Weston
plugin (disabled by default) and a client named "weston-
qa-client".
Currently, if the plugin is enabled in "weston.ini", the
client will retrieve a list of the currently displayed
surfaces along with their positions and sizes.
Change-Id: I881131f1985ef527dfd45e27a66edd5fce2d55c8
Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
-rw-r--r-- | packaging/weston-common.spec | 15 | ||||
-rw-r--r-- | src/COPYING | 1 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/configure.ac | 11 | ||||
-rw-r--r-- | src/qa-plugin/Makefile.am | 45 | ||||
-rw-r--r-- | src/qa-plugin/qa-client.c | 87 | ||||
-rw-r--r-- | src/qa-plugin/qa-plugin.c | 83 | ||||
-rw-r--r-- | src/qa-plugin/qa.xml | 14 | ||||
-rw-r--r-- | weston.ini | 1 |
9 files changed, 258 insertions, 1 deletions
diff --git a/packaging/weston-common.spec b/packaging/weston-common.spec index 6faae7f..138d003 100644 --- a/packaging/weston-common.spec +++ b/packaging/weston-common.spec @@ -25,6 +25,8 @@ BuildRequires: pkgconfig(xkbcommon) BuildRequires: pkgconfig(wayland-client) BuildRequires: pkgconfig(wayland-cursor) BuildRequires: pkgconfig(wayland-egl) +BuildRequires: pkgconfig(wayland-scanner) +BuildRequires: pkgconfig(wayland-server) BuildRequires: pkgconfig(egl) BuildRequires: pkgconfig(glesv2) BuildRequires: pkgconfig(pixman-1) @@ -45,6 +47,12 @@ Summary: A small launcher for Wayland compositors %description tz-launcher A small launcher for Wayland compositors, which reads .desktop files from paths given on the command line or in a config file, and then displays them graphically. +############ qa-plugin +%package qa-plugin +Summary: A Q&A plugin for Weston + +%description qa-plugin +A small Weston plugin, disabled by default, which enables features such as listing surfaces along with positions and coordinates. ############ %description @@ -172,3 +180,10 @@ rm -f %{_unitdir_user}/default.target.requires/weston-user.service %license src/COPYING %{_bindir}/tz-launcher %{_bindir}/wl-pre + +%files qa-plugin +%manifest %{name}.manifest +%defattr(-,root,root) +%license src/COPYING +%{_bindir}/weston-qa-client +%{_libdir}/weston/qa-plugin.so diff --git a/src/COPYING b/src/COPYING index 6ba3d98..cfbf164 100644 --- a/src/COPYING +++ b/src/COPYING @@ -2,6 +2,7 @@ Copyright © 2008-2012 Kristian Høgsberg Copyright © 2010-2012 Intel Corporation Copyright © 2011 Benjamin Franzke Copyright © 2012 Collabora, Ltd. +Copyright © 2014 Manuel Bachmann Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that diff --git a/src/Makefile.am b/src/Makefile.am index ce29423..4c0a48e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,7 @@ bin_PROGRAMS = +SUBDIRS=qa-plugin + all-local : AM_CFLAGS = $(GCC_CFLAGS) diff --git a/src/configure.ac b/src/configure.ac index 002bf69..d175d14 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -93,6 +93,8 @@ PKG_CHECK_MODULES(GLIB, [glib-2.0 gio-2.0]) PKG_CHECK_MODULES(CLIENT, [wayland-client cairo >= 1.10.0 xkbcommon wayland-cursor]) +PKG_CHECK_MODULES(SERVER, [wayland-server]) + # Only check for cairo-egl if a GL or GLES renderer requested AS_IF([test "x$cairo_modules" = "xcairo-glesv2"], [ PKG_CHECK_MODULES(CAIRO_EGL, [wayland-egl egl >= 7.10 cairo-egl >= 1.11.3 $cairo_modules], @@ -105,7 +107,14 @@ PKG_CHECK_MODULES(CLIENT, [wayland-client cairo >= 1.10.0 xkbcommon wayland-curs AM_CONDITIONAL(HAVE_CAIRO_GLESV2, [test "x$have_cairo_egl" = "xyes" -a "x$cairo_modules" = "xcairo-glesv2" -a "x$enable_egl" = "xyes"]) -AC_CONFIG_FILES([Makefile]) +AC_PATH_PROG([wayland_scanner], [wayland-scanner]) +if test x$wayland_scanner = x; then + AC_MSG_ERROR([wayland-scanner is needed to compile the qa plugin]) +fi + +PKG_CHECK_MODULES(WAYLAND_SCANNER, wayland-scanner) + +AC_CONFIG_FILES([Makefile qa-plugin/Makefile]) AC_OUTPUT diff --git a/src/qa-plugin/Makefile.am b/src/qa-plugin/Makefile.am new file mode 100644 index 0000000..7d217f7 --- /dev/null +++ b/src/qa-plugin/Makefile.am @@ -0,0 +1,45 @@ +bin_PROGRAMS = +moduledir = $(libdir)/weston +module_LTLIBRARIES = + +all-local : + +AM_CFLAGS = $(GCC_CFLAGS) + +AM_CPPFLAGS = + +CLEANFILES = + +BUILT_SOURCES = \ + qa-protocol.c \ + qa-server-protocol.h \ + qa-client-protocol.h + +qa-protocol.c : qa.xml + $(wayland_scanner) code < $< > $@ +qa-server-protocol.h : qa.xml + $(wayland_scanner) server-header < $< > $@ +qa-client-protocol.h : qa.xml + $(wayland_scanner) client-header < $< > $@ + +bin_PROGRAMS += weston-qa-client + +weston_qa_client_LDFLAGS = -export-dynamic +weston_qa_client_CPPFLAGS = $(AM_CPPFLAGS) +weston_qa_client_CFLAGS = $(GCC_CFLAGS) $(CLIENT_CFLAGS) +weston_qa_client_LDADD = $(DLOPEN_LIBS) $(CLIENT_LIBS) + +weston_qa_client_SOURCES = \ + qa-client.c \ + qa-protocol.c + +module_LTLIBRARIES += qa-plugin.la + +qa_plugin_la_LDFLAGS = -module -avoid-version +qa_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -Wno-unused-result +qa_plugin_la_CFLAGS = $(GCC_CFLAGS) $(SERVER_CFLAGS) $(PIXMAN_CFLAGS) +qa_plugin_la_LIBADD = $(DLOPEN_LIBS) $(SERVER_LIBS) $(PIXMAN_LIBS) + +qa_plugin_la_SOURCES = \ + qa-plugin.c \ + qa-protocol.c diff --git a/src/qa-plugin/qa-client.c b/src/qa-plugin/qa-client.c new file mode 100644 index 0000000..24451f0 --- /dev/null +++ b/src/qa-plugin/qa-client.c @@ -0,0 +1,87 @@ + /* Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net> */ + +#include <stdio.h> +#include <string.h> +#include <wayland-client.h> + +#include "qa-client-protocol.h" +struct qa *qa = NULL; +int done = 0; + + +static void +qa_handle_surface_list (void *data, struct qa *qa, + const char *list) +{ + printf ("qa-client: SURFACES LIST :\n%s", list); + done = 1; +} + +static const struct qa_listener qa_listener = { + qa_handle_surface_list +}; + +static void +registry_handle_global (void *data, struct wl_registry *registry, + uint32_t id, const char *interface, uint32_t version) +{ + if (strcmp (interface, "qa") == 0) { + qa = wl_registry_bind (registry, id, + &qa_interface, version); + printf ("qa-client: registered the \"qa\" interface.\n"); + } +} + +static void +registry_handle_global_remove (void *data, struct wl_registry *registry, + uint32_t name) +{ +} + +static const struct wl_registry_listener registry_listener = { + registry_handle_global, + registry_handle_global_remove +}; + + +int main (int argc, char *argv[]) +{ + struct wl_display *display = NULL; + struct wl_registry *registry = NULL; + int res = 0; + + display = wl_display_connect (NULL); + if (!display) { + printf ("qa-client: display error.\n"); + printf ("Did you define XDG_RUNTIME_DIR ?\n"); + return -1; + } + + registry = wl_display_get_registry (display); + if (!registry) { + printf ("qa-client: registry error.\n"); + return -1; + } + + wl_registry_add_listener (registry, ®istry_listener, NULL); + + printf ("Waiting for the \"qa\" interface...\n"); + while (!qa) + wl_display_roundtrip (display); + + + qa_add_listener (qa, &qa_listener, NULL); + + qa_surface_list (qa); + + while ((res != -1) && (done == 0)) + res = wl_display_dispatch (display); + + + qa_destroy (qa); + wl_registry_destroy (registry); + wl_display_flush (display); + wl_display_disconnect (display); + + return 0; +} diff --git a/src/qa-plugin/qa-plugin.c b/src/qa-plugin/qa-plugin.c new file mode 100644 index 0000000..dc095d4 --- /dev/null +++ b/src/qa-plugin/qa-plugin.c @@ -0,0 +1,83 @@ + /* Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net> */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <wayland-server.h> + +#include <weston/compositor.h> +#include "qa-server-protocol.h" + +struct weston_compositor *ec = NULL; + + + +static void +qa_surface_list (struct wl_client *client, + struct wl_resource *resource) +{ + struct weston_view *view; + char *resp, *temp; + + weston_log ("qa-plugin: requested surfaces list...\n"); + + resp = strdup (""); + + wl_list_for_each (view, &ec->view_list, link) { printf ("RHA "); + if ((view->surface) && + (view->geometry.x != 0.0) && + (view->geometry.y != 0.0)) { + asprintf (&temp, "Surface %p : X+Y = %.2f+%.2f - WxH = %dx%d\n", + view->surface, view->geometry.x, view->geometry.y, + view->surface->width, view->surface->height); + resp = realloc (resp, strlen(resp) + strlen (temp) + 1); + strncat (resp, temp, strlen(temp)); + free (temp); + } + } + + qa_send_list_surface (resource, resp); + free (resp); +} + +static void +qa_destroy (struct wl_client *client, + struct wl_resource *resource) +{ + wl_resource_destroy (resource); +} + +static const struct qa_interface qa_implementation = { + qa_surface_list, + qa_destroy +}; + +static void +bind_qa (struct wl_client *client, void *data, + uint32_t version, uint32_t id) +{ + struct wl_resource *resource; + + resource = wl_resource_create (client, &qa_interface, + 1, id); + wl_resource_set_implementation (resource, &qa_implementation, + NULL, NULL); +} + +WL_EXPORT int +module_init (struct weston_compositor *compositor, + int *argc, char *argv[]) +{ + ec = compositor; + + weston_log ("qa-plugin: initialization.\n"); + + if (wl_global_create (ec->wl_display, &qa_interface, + 1, NULL, bind_qa) == NULL) + { + weston_log ("qa-plugin: could not bind the \"qa\" interface, exiting...\n"); + return -1; + } + + return 0; +} diff --git a/src/qa-plugin/qa.xml b/src/qa-plugin/qa.xml new file mode 100644 index 0000000..b804b64 --- /dev/null +++ b/src/qa-plugin/qa.xml @@ -0,0 +1,14 @@ +<protocol name="qa"> + + <interface name="qa" version="1"> + + <request name="surface_list"/> + <request name="destroy" type="destructor"/> + + <event name="list_surface"> + <arg name="list" type="string"/> + </event> + + </interface> + +</protocol> @@ -1,5 +1,6 @@ [core] modules=desktop-shell.so +#modules=desktop-shell.so,qa-plugin.so [shell] background-image=/usr/share/backgrounds/tizen/current |