/** * @file * @section AUTHORS * * Authors: * Eamon Walsh * * @section LICENSE * * This file is in the public domain. * * @section DESCRIPTION * * This is the "subclass" of display that implements a single view * consisting of the entirety of a buffer. In other words, this is the * standard client display for doing a fullscreen framebuffer from a guest. * With the exception of the combined desktop and the server screen, all * of the display objects will be of this type. */ #include #include #include #include #include "sys-queue.h" #include "xen_linpicker.h" #include "client.h" #include "view.h" #include "display.h" #include "input.h" static int bclient_key(struct display *d, bool down, int keycode) { if (d->client->input) xenfb_send_key(d->client->input, down, keycode); return 0; } static int bclient_position(struct display *d, int x, int y) { struct view *v; struct client *c; TAILQ_FOREACH(v, &d->views, display_next) if (x >= v->spos.x && x < (v->spos.x + v->spos.w) && y >= v->spos.y && y < (v->spos.y + v->spos.h)) break; /* What client is the mouse over? */ c = v ? v->buffer->client : NULL; /* Mouselabel update */ if (c != d->mouse_client) { d->mouse_client = c; display_update_mouselabel(d, c); } return 0; } static int bclient_mouse(struct display *d, struct mouse_event *m) { struct buffer *b = LIST_FIRST(&d->buffers); /* Update position */ bclient_position(d, m->x, m->y); /* Remove the buffer offset */ /* Clamp the position to the buffer bounds */ /* Scale the position to the dimensions the frontend expects */ if (b->xoff > 0 || b->yoff > 0) { m->x = scale_value(m->x - b->xoff, b->desc.width, display_get_width()); m->y = scale_value(m->y - b->yoff, b->desc.height, display_get_height()); } if (d->client->input) xen_linpicker_input_send(d->client->input, m); return 0; } struct display * bclient_new(struct buffer *b) { struct display *d = calloc(1, sizeof(struct display)); if (!d) return NULL; /* Set up input methods */ d->send_key = bclient_key; d->send_mouse = bclient_mouse; d->update_position = bclient_position; d->type = DISPLAY_BUFFER; d->client = b->client; LIST_INIT(&d->buffers); LIST_INSERT_HEAD(&d->buffers, b, display_next); TAILQ_INIT(&d->views); d->bg_view = b->bg_view; return d; }