diff options
Diffstat (limited to 'tests/x11/test_tablet_native.c')
| -rw-r--r-- | tests/x11/test_tablet_native.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/tests/x11/test_tablet_native.c b/tests/x11/test_tablet_native.c index 706a5cc..828082c 100644 --- a/tests/x11/test_tablet_native.c +++ b/tests/x11/test_tablet_native.c @@ -2,7 +2,7 @@ #define main tablet_example_main #include "../../examples/tablet.c" #undef main -#include <yasl/native.h> +#include <common/private_native.h> #include <X11/Xatom.h> #include <X11/Xlib.h> #include <X11/Xutil.h> @@ -55,24 +55,24 @@ static int connect_tool(const char *path) return fd; } -static void native_draw(struct yasl_surface *surface, struct yasl_frame *frame, void *ud) +static void native_draw(struct yasl_surface *surface, struct yasl_private_frame *frame, void *ud) { (void)surface; draw(ud, surface, frame); } -static void native_configure(struct yasl_surface *surface, struct yasl_geometry geometry, void *ud) +static void native_configure(struct yasl_surface *surface, struct yasl_private_geometry geometry, void *ud) { - input(ud, &(struct yasl_event){.surface = surface, .type = YASL_EVENT_WINDOW_RESIZE, + input(ud, &(struct yasl_private_event){.surface = surface, .type = YASL_PRIVATE_EVENT_WINDOW_RESIZE, .resize = {.geometry = geometry}}); } -static void native_input(struct app *app, const struct yasl_event *event) +static void native_input(struct app *app, const struct yasl_private_event *event) { input(app, event); } -static void pump(int fd, struct yasl_display *display, struct yasl_surface *surface, struct app *app) +static void pump(int fd, struct yasl_private_display *display, struct yasl_surface *surface, struct app *app) { xf86ITEventWaitForSync sync = {{sizeof(sync), XF86IT_EVENT_WAIT_FOR_SYNC}}; send_all(fd, &sync, sizeof(sync)); @@ -81,14 +81,14 @@ static void pump(int fd, struct yasl_display *display, struct yasl_surface *surf assert(response.type == XF86IT_RESPONSE_SYNC_FINISHED && response.length == sizeof(response)); /* The driver acknowledgment guarantees input processing has finished. * Round-trip on YASL's X connection before draining its event queue. */ - XSync(yasl_display_get_native_handle(display), False); - assert(yasl_display_dispatch(display, 0) == 0); - struct yasl_event event; - while (yasl_surface_poll_event(surface, &event)) { + XSync(yasl_private_display_get_native_handle(display), False); + assert(yasl_private_display_dispatch(display, 0) == 0); + struct yasl_private_event event; + while (yasl_private_surface_poll_event(surface, &event)) { native_input(app, &event); - yasl_surface_schedule_redraw(surface); + yasl_private_surface_schedule_redraw(surface); } - yasl_display_flush(display); + yasl_private_display_flush(display); assert(!app->failed); } @@ -116,23 +116,23 @@ static void set_eraser_property(Display *display) int main(int argc, char **argv) { assert(argc == 3); /* pen socket, eraser socket */ - struct app app = {.tablet_supported = true, .backend = YASL_BACKEND_X11}; - struct yasl_display_spec ds = {.backend = YASL_BACKEND_X11}; - struct yasl_display *display = yasl_display_open(NULL, &ds); - assert(display && (yasl_display_caps(display) & YASL_CAP_TABLET)); - struct yasl_window_spec ss = {.title = "YASL native pressure test", .size = {500, 400}}; - struct yasl_surface *surface = yasl_surface_create_toplevel(display, &ss); + struct app app = {.tablet_supported = true, .backend = YASL_PRIVATE_BACKEND_X11}; + struct yasl_private_display_spec ds = {.backend = YASL_PRIVATE_BACKEND_X11}; + struct yasl_private_display *display = yasl_private_display_open(NULL, &ds); + assert(display && (yasl_private_display_caps(display) & YASL_PRIVATE_CAP_TABLET)); + struct yasl_private_window_spec ss = {.title = "YASL native pressure test", .size = {500, 400}}; + struct yasl_surface *surface = yasl_private_surface_create_toplevel(display, &ss); assert(surface); - struct yasl_window_cbs cbs = {.draw = native_draw, .configure = native_configure}; - yasl_surface_set_callbacks(surface, &cbs, &app); - yasl_surface_schedule_redraw(surface); - Display *x = yasl_display_get_native_handle(display); - Window window = (Window)(uintptr_t)yasl_surface_get_native_handle(surface); + struct yasl_private_window_cbs cbs = {.draw = native_draw, .configure = native_configure}; + yasl_private_surface_set_callbacks(surface, &cbs, &app); + yasl_private_surface_schedule_redraw(surface); + Display *x = yasl_private_display_get_native_handle(display); + Window window = (Window)(uintptr_t)yasl_private_surface_get_native_handle(surface); XMoveWindow(x, window, 0, 0); XSetInputFocus(x, window, RevertToParent, CurrentTime); XSync(x, False); - assert(yasl_display_dispatch(display, 0) == 0); - yasl_display_flush(display); + assert(yasl_private_display_dispatch(display, 0) == 0); + yasl_private_display_flush(display); set_eraser_property(x); int pen_fd = connect_tool(argv[1]), eraser_fd = connect_tool(argv[2]); xf86ITEventMotion motion = {.header = {sizeof(motion), XF86IT_EVENT_MOTION}, .is_absolute = 1}; @@ -144,7 +144,7 @@ int main(int argc, char **argv) send_all(pen_fd, &proximity, sizeof(proximity)); send_all(pen_fd, &motion, sizeof(motion)); pump(pen_fd, display, surface, &app); - assert(app.visible && !app.down && app.pointer.device == YASL_PTR_DEV_PEN); + assert(app.visible && !app.down && app.pointer.device == YASL_PRIVATE_PTR_DEV_PEN); assert(app.pointer.pos.x == 150 && app.pointer.pos.y == 200); assert(app.canvas[(size_t)200 * app.geometry.size.x + 150] == PAPER); xf86ITEventButton button = {.header = {sizeof(button), XF86IT_EVENT_BUTTON}, @@ -177,7 +177,7 @@ int main(int argc, char **argv) button.valuators.valuators[4] = 1000; send_all(eraser_fd, &button, sizeof(button)); pump(eraser_fd, display, surface, &app); - assert(app.down && app.pointer.device == YASL_PTR_DEV_ERASER && app.pointer.pen.pressure == 65535); + assert(app.down && app.pointer.device == YASL_PRIVATE_PTR_DEV_ERASER && app.pointer.pen.pressure == 65535); assert(app.canvas[(size_t)200 * app.geometry.size.x + 150] == PAPER && app.canvas[(size_t)200 * app.geometry.size.x + 170] == PAPER); button.is_press = 0; @@ -187,8 +187,8 @@ int main(int argc, char **argv) close(pen_fd); close(eraser_fd); free(app.canvas); - yasl_surface_destroy(surface); - yasl_display_close(display); + yasl_private_surface_destroy(surface); + yasl_private_display_close(display); puts("Native Xorg pen pressure, stationary pressure, release, and eraser drawing passed."); return 0; } |
