2 * Copyright © 2012 Intel Corporation
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 #include <sys/socket.h>
29 #include <linux/input.h>
31 #include "test-runner.h"
34 struct weston_layer *layer;
35 struct weston_seat *seat;
36 struct weston_surface *surface;
40 handle_button_up(struct test_client *);
43 handle_button_down(struct test_client *client)
45 struct context *context = client->data;
48 assert(sscanf(client->buf, "%u", &mask) == 1);
52 notify_button(context->seat, 100, BTN_LEFT,
53 WL_POINTER_BUTTON_STATE_RELEASED);
55 test_client_send(client, "send-button-state\n");
56 client->handle = handle_button_up;
60 handle_button_up(struct test_client *client)
62 struct context *context = client->data;
66 assert(sscanf(client->buf, "%u", &mask) == 1);
71 notify_button(context->seat, 100, BTN_LEFT,
72 WL_POINTER_BUTTON_STATE_PRESSED);
74 test_client_send(client, "send-button-state\n");
75 client->handle = handle_button_down;
77 test_client_send(client, "bye\n");
78 client->handle = NULL;
83 handle_surface(struct test_client *client)
86 struct context *context = client->data;
87 struct wl_resource *resource;
88 struct wl_list *seat_list;
90 assert(sscanf(client->buf, "surface %u", &id) == 1);
91 fprintf(stderr, "server: got surface id %u\n", id);
92 resource = wl_client_get_object(client->client, id);
94 assert(strcmp(resource->object.interface->name, "wl_surface") == 0);
96 context->surface = (struct weston_surface *) resource;
97 weston_surface_set_color(context->surface, 0.0, 0.0, 0.0, 1.0);
99 context->layer = malloc(sizeof *context->layer);
100 assert(context->layer);
101 weston_layer_init(context->layer,
102 &client->compositor->cursor_layer.link);
103 wl_list_insert(&context->layer->surface_list,
104 &context->surface->layer_link);
106 seat_list = &client->compositor->seat_list;
107 assert(wl_list_length(seat_list) == 1);
108 context->seat = container_of(seat_list->next, struct weston_seat, link);
110 client->compositor->focus = 1; /* Make it work even if pointer is
111 * outside X window. */
113 weston_surface_configure(context->surface, 100, 100, 100, 100);
114 weston_surface_update_transform(context->surface);
115 weston_surface_damage(context->surface);
117 notify_pointer_focus(context->seat, context->surface->output,
118 wl_fixed_from_int(150), wl_fixed_from_int(150));
120 test_client_send(client, "send-button-state\n");
121 client->handle = handle_button_up;
126 struct context *context;
127 struct test_client *client;
129 client = test_client_launch(compositor, "test-client");
130 client->terminate = 1;
132 test_client_send(client, "create-surface\n");
133 client->handle = handle_surface;
135 context = calloc(1, sizeof *context);
137 client->data = context;