From: Manuel Bachmann Date: Fri, 13 Feb 2015 11:21:16 +0000 (+0100) Subject: QA plugin: add an API to move a surface, adapt client X-Git-Tag: accepted/tizen/3.0.2014.q4/common/20150213.132739^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_3.0.2014.q4_common;p=profile%2Fcommon%2Fweston-common.git QA plugin: add an API to move a surface, adapt client Enabling the QA plugin and using "weston-qa-client --move " now permits to change a surface position with the command line. (former display command is now : "weston-qa-client --list") Change-Id: Ia43edad05d31747ef8f5a5d4bb4a727340ec39da Signed-off-by: Manuel Bachmann --- diff --git a/src/qa-plugin/qa-client.c b/src/qa-plugin/qa-client.c index 24451f0..133baf9 100644 --- a/src/qa-plugin/qa-client.c +++ b/src/qa-plugin/qa-client.c @@ -1,6 +1,7 @@ /* Copyright 2014 Manuel Bachmann */ #include +#include #include #include @@ -13,12 +14,20 @@ static void qa_handle_surface_list (void *data, struct qa *qa, const char *list) { - printf ("qa-client: SURFACES LIST :\n%s", list); + printf ("SURFACES LIST :\n%s", list); + done = 1; +} + +static void +qa_handle_surface_move (void *data, struct qa *qa) +{ + printf ("SURFACE MOVE...\n"); done = 1; } static const struct qa_listener qa_listener = { - qa_handle_surface_list + qa_handle_surface_list, + qa_handle_surface_move }; static void @@ -28,7 +37,7 @@ registry_handle_global (void *data, struct wl_registry *registry, if (strcmp (interface, "qa") == 0) { qa = wl_registry_bind (registry, id, &qa_interface, version); - printf ("qa-client: registered the \"qa\" interface.\n"); + printf ("weston-qa-client: registered the \"qa\" interface.\n\n"); } } @@ -46,20 +55,30 @@ static const struct wl_registry_listener registry_listener = { int main (int argc, char *argv[]) { + if (((argc != 2) && (argc != 5)) || + ((argc == 2) && (strcmp(argv[1],"--help") == 0)) || + ((argc == 2) && (strcmp(argv[1],"--list") != 0)) || + ((argc == 5) && (strcmp(argv[1],"--move") != 0))) { + printf ("Usage : weston-qa-client --list : list displayed surfaces\n"); + printf (" weston-qa-client --move : move surface to position\n"); + printf (" weston-qa-client --help : this help section\n\n"); + return 0; + } + 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 ("weston-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"); + printf ("weston-qa-client: registry error.\n"); return -1; } @@ -72,7 +91,13 @@ int main (int argc, char *argv[]) qa_add_listener (qa, &qa_listener, NULL); - qa_surface_list (qa); + if ((argc == 2) && (strcmp(argv[1],"--list") == 0)) { + qa_surface_list (qa); + } else if ((argc == 5) && (strcmp(argv[1],"--move") == 0)) { + qa_surface_move (qa, atoi(argv[2]), + atoi(argv[3]), + atoi(argv[4])); + } while ((res != -1) && (done == 0)) res = wl_display_dispatch (display); diff --git a/src/qa-plugin/qa-plugin.c b/src/qa-plugin/qa-plugin.c index dc095d4..069e055 100644 --- a/src/qa-plugin/qa-plugin.c +++ b/src/qa-plugin/qa-plugin.c @@ -23,12 +23,13 @@ qa_surface_list (struct wl_client *client, resp = strdup (""); - wl_list_for_each (view, &ec->view_list, link) { printf ("RHA "); + wl_list_for_each (view, &ec->view_list, link) { 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, + asprintf (&temp, "Surface %d : X+Y = %.2f+%.2f - WxH = %dx%d\n", + (unsigned int) 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)); @@ -41,6 +42,29 @@ qa_surface_list (struct wl_client *client, } static void +qa_surface_move (struct wl_client *client, + struct wl_resource *resource, + uint32_t id, + uint32_t x, + uint32_t y) +{ + struct weston_view *view; + + weston_log ("qa-plugin: requested to move surface %d to %d+%d...\n", id, x, y); + + wl_list_for_each (view, &ec->view_list, link) { + if ((view->surface) && + ((unsigned int) view->surface == id)) { + view->geometry.x = (float) x; + view->geometry.y = (float) y; + view->transform.dirty = 1; + } + } + + qa_send_move_surface (resource); +} + +static void qa_destroy (struct wl_client *client, struct wl_resource *resource) { @@ -49,6 +73,7 @@ qa_destroy (struct wl_client *client, static const struct qa_interface qa_implementation = { qa_surface_list, + qa_surface_move, qa_destroy }; diff --git a/src/qa-plugin/qa.xml b/src/qa-plugin/qa.xml index b804b64..1ee7fd8 100644 --- a/src/qa-plugin/qa.xml +++ b/src/qa-plugin/qa.xml @@ -3,12 +3,21 @@ + + + + + + + + +