QA plugin: add an API to move a surface, adapt client 14/35414/1 accepted/tizen_3.0.2014.q4_common tizen_3.0.2014.q4_common accepted/tizen/3.0.2014.q4/common/20150213.132739 accepted/tizen/common/20150213.132414 accepted/tizen/mobile/20150319.013836 submit/tizen_3.0.2014.q4_common/20150213.132410 submit/tizen_common/20150213.114617 submit/tizen_mobile/20150318.102757
authorManuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Fri, 13 Feb 2015 11:21:16 +0000 (12:21 +0100)
committerManuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Fri, 13 Feb 2015 11:21:16 +0000 (12:21 +0100)
Enabling the QA plugin and using "weston-qa-client --move
<ID> <x> <y>" 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 <manuel.bachmann@open.eurogiciel.org>
src/qa-plugin/qa-client.c
src/qa-plugin/qa-plugin.c
src/qa-plugin/qa.xml

index 24451f0..133baf9 100644 (file)
@@ -1,6 +1,7 @@
  /* Copyright 2014 Manuel Bachmann <tarnyko@tarnyko.net> */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <wayland-client.h>
 
@@ -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 <ID> <x> <y> : 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);
index dc095d4..069e055 100644 (file)
@@ -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
 };
 
index b804b64..1ee7fd8 100644 (file)
@@ -3,12 +3,21 @@
   <interface name="qa" version="1">
 
     <request name="surface_list"/>
+
+    <request name="surface_move">
+      <arg name="id" type="uint"/>
+      <arg name="x" type="uint"/>
+      <arg name="y" type="uint"/>
+    </request>
+
     <request name="destroy" type="destructor"/>
 
     <event name="list_surface">
       <arg name="list" type="string"/>
     </event>
 
+    <event name="move_surface"/>
+
   </interface>
 
 </protocol>