{
struct wl_object *object;
uint32_t args[32], length, *p, size;
+ struct wl_array *array;
const char *s;
int i, count;
object = va_arg(ap, struct wl_object *);
*p++ = object ? object->id : 0;
break;
+ case 'a':
+ array = va_arg(ap, struct wl_array *);
+ if (array == NULL || array->size == 0) {
+ *p++ = 0;
+ break;
+ }
+ *p++ = array->size;
+ memcpy(p, array->data, array->size);
+ p = (void *) p + array->size;
+ break;
default:
assert(0);
break;
char *string;
void *object;
uint32_t new_id;
+ struct wl_array *array;
} values[20];
void *args[20];
struct wl_object *object;
printf("object already exists (%d)\n", *p);
p++;
break;
+ case 'a':
+ types[i] = &ffi_type_pointer;
+ length = *p++;
+ values[i].array = malloc(length + sizeof *values[i].array);
+ if (values[i].array == NULL) {
+ /* FIXME: Send NO_MEMORY */
+ return;
+ }
+ values[i].array->size = length;
+ values[i].array->alloc = 0;
+ values[i].array->data = values[i].array + 1;
+ memcpy(values[i].array->data, p, length);
+ p += DIV_ROUNDUP(length, sizeof *p);
+ break;
default:
printf("unknown type\n");
break;
case 's':
free(values[i].string);
break;
+ case 'a':
+ free(values[i].array);
+ break;
}
}
}
struct wl_surface *surface);
void (*keyboard_focus)(void *data,
struct wl_input_device *input_device,
- struct wl_surface *surface);
+ struct wl_surface *surface,
+ struct wl_array *keys);
};
int
{ "button", "uuiiii" },
{ "key", "uu" },
{ "pointer_focus", "o" },
- { "keyboard_focus", "o" },
+ { "keyboard_focus", "oa" },
};
WL_EXPORT const struct wl_interface wl_input_device_interface = {
struct wlsc_surface *grab_surface;
struct wlsc_surface *pointer_focus;
struct wlsc_surface *keyboard_focus;
+ struct wl_array keys;
};
struct wlsc_compositor {
(!surface || device->keyboard_focus->base.client != surface->base.client))
wl_surface_post_event(&device->keyboard_focus->base,
&device->base,
- WL_INPUT_KEYBOARD_FOCUS, NULL);
+ WL_INPUT_KEYBOARD_FOCUS, NULL, NULL);
- /* FIXME: We need to send the currently held down keys in the
- * keyboard focus event. */
if (surface)
wl_surface_post_event(&surface->base,
&device->base,
- WL_INPUT_KEYBOARD_FOCUS, &surface->base);
+ WL_INPUT_KEYBOARD_FOCUS,
+ &surface->base, &device->keys);
device->keyboard_focus = surface;
}
uint32_t key, uint32_t state)
{
struct wlsc_compositor *ec = device->ec;
+ uint32_t *k, *end;
+
+ if (!ec->vt_active)
+ return;
switch (key | ec->meta_state) {
case KEY_EJECTCD | META_DOWN:
return;
}
- if (!ec->vt_active)
- return;
+ end = device->keys.data + device->keys.size;
+ for (k = device->keys.data; k < end; k++) {
+ if (*k == key)
+ *k = *--end;
+ }
+ device->keys.size = (void *) end - device->keys.data;
+ if (state) {
+ k = wl_array_add(&device->keys, sizeof *k);
+ *k = key;
+ }
if (device->keyboard_focus != NULL)
wl_surface_post_event(&device->keyboard_focus->base,
{
return list->next == list;
}
+
+void
+wl_array_init(struct wl_array *array)
+{
+ memset(array, 0, sizeof *array);
+}
+
+void
+wl_array_release(struct wl_array *array)
+{
+ free(array->data);
+}
+
+void *
+wl_array_add(struct wl_array *array, int size)
+{
+ int alloc;
+ void *data, *p;
+
+ if (array->alloc > 0)
+ alloc = array->alloc;
+ else
+ alloc = 16;
+
+ while (alloc < array->size + size)
+ alloc *= 2;
+
+ if (array->alloc < alloc) {
+ if (array->alloc > 0)
+ data = realloc(array->data, alloc);
+ else
+ data = malloc(alloc);
+
+ if (data == NULL)
+ return 0;
+ array->data = data;
+ array->alloc = alloc;
+ }
+
+ p = array->data + array->size;
+ array->size += size;
+
+ return p;
+}
int wl_list_length(struct wl_list *list);
int wl_list_empty(struct wl_list *list);
+struct wl_array {
+ uint32_t size;
+ uint32_t alloc;
+ void *data;
+};
+
+void wl_array_init(struct wl_array *array);
+void wl_array_release(struct wl_array *array);
+void *wl_array_add(struct wl_array *array, int size);
#endif
#include <cairo-drm.h>
#include <linux/input.h>
+#include "wayland-util.h"
#include "wayland-client.h"
#include "wayland-glib.h"
static void
window_handle_keyboard_focus(void *data,
struct wl_input_device *input_device,
- struct wl_surface *surface)
+ struct wl_surface *surface,
+ struct wl_array *keys)
{
struct window *window = data;