shell_resize(NULL,
(struct wl_shell *) &compositor->shell,
&surface->surface, device, time,
- WL_GRAB_RESIZE_BOTTOM_RIGHT);
+ WL_SHELL_RESIZE_BOTTOM_RIGHT);
if (device->grab)
device->grab->interface->button(device->grab, time,
struct wl_surface *surface = &resize->surface->surface;
int32_t width, height;
- if (resize->edges & WL_GRAB_RESIZE_LEFT) {
+ if (resize->edges & WL_SHELL_RESIZE_LEFT) {
width = device->grab_x - x + resize->width;
- } else if (resize->edges & WL_GRAB_RESIZE_RIGHT) {
+ } else if (resize->edges & WL_SHELL_RESIZE_RIGHT) {
width = x - device->grab_x + resize->width;
} else {
width = resize->width;
}
- if (resize->edges & WL_GRAB_RESIZE_TOP) {
+ if (resize->edges & WL_SHELL_RESIZE_TOP) {
height = device->grab_y - y + resize->height;
- } else if (resize->edges & WL_GRAB_RESIZE_BOTTOM) {
+ } else if (resize->edges & WL_SHELL_RESIZE_BOTTOM) {
height = y - device->grab_y + resize->height;
} else {
height = resize->height;
return;
switch (edges) {
- case WL_GRAB_RESIZE_TOP:
+ case WL_SHELL_RESIZE_TOP:
pointer = WLSC_POINTER_TOP;
break;
- case WL_GRAB_RESIZE_BOTTOM:
+ case WL_SHELL_RESIZE_BOTTOM:
pointer = WLSC_POINTER_BOTTOM;
break;
- case WL_GRAB_RESIZE_LEFT:
+ case WL_SHELL_RESIZE_LEFT:
pointer = WLSC_POINTER_LEFT;
break;
- case WL_GRAB_RESIZE_TOP_LEFT:
+ case WL_SHELL_RESIZE_TOP_LEFT:
pointer = WLSC_POINTER_TOP_LEFT;
break;
- case WL_GRAB_RESIZE_BOTTOM_LEFT:
+ case WL_SHELL_RESIZE_BOTTOM_LEFT:
pointer = WLSC_POINTER_BOTTOM_LEFT;
break;
- case WL_GRAB_RESIZE_RIGHT:
+ case WL_SHELL_RESIZE_RIGHT:
pointer = WLSC_POINTER_RIGHT;
break;
- case WL_GRAB_RESIZE_TOP_RIGHT:
+ case WL_SHELL_RESIZE_TOP_RIGHT:
pointer = WLSC_POINTER_TOP_RIGHT;
break;
- case WL_GRAB_RESIZE_BOTTOM_RIGHT:
+ case WL_SHELL_RESIZE_BOTTOM_RIGHT:
pointer = WLSC_POINTER_BOTTOM_RIGHT;
break;
}
<arg name="time" type="uint"/>
</request>
+ <enum name="resize">
+ <entry name="none" value="0"/>
+ <entry name="top" value="1"/>
+ <entry name="bottom" value="2"/>
+ <entry name="left" value="4"/>
+ <entry name="top_left" value="5"/>
+ <entry name="bottom_left" value="6"/>
+ <entry name="right" value="8"/>
+ <entry name="top_right" value="9"/>
+ <entry name="bottom_right" value="10"/>
+ </enum>
+
<request name="resize">
<arg name="surface" type="object" interface="surface"/>
<arg name="input_device" type="object" interface="input_device"/>
int version;
struct wl_list request_list;
struct wl_list event_list;
+ struct wl_list enumeration_list;
struct wl_list link;
};
struct wl_list link;
};
+struct enumeration {
+ char *name;
+ char *uppercase_name;
+ struct wl_list entry_list;
+ struct wl_list link;
+};
+
+struct entry {
+ char *name;
+ char *uppercase_name;
+ char *value;
+ struct wl_list link;
+};
+
struct parse_context {
struct protocol *protocol;
struct interface *interface;
struct message *message;
+ struct enumeration *enumeration;
};
static char *
struct interface *interface;
struct message *message;
struct arg *arg;
- const char *name, *type, *interface_name;
+ struct enumeration *enumeration;
+ struct entry *entry;
+ const char *name, *type, *interface_name, *value;
int i, version;
name = NULL;
type = NULL;
version = 0;
interface_name = NULL;
+ value = NULL;
for (i = 0; atts[i]; i += 2) {
if (strcmp(atts[i], "name") == 0)
name = atts[i + 1];
version = atoi(atts[i + 1]);
if (strcmp(atts[i], "type") == 0)
type = atts[i + 1];
+ if (strcmp(atts[i], "value") == 0)
+ value = atts[i + 1];
if (strcmp(atts[i], "interface") == 0)
interface_name = atts[i + 1];
}
interface->version = version;
wl_list_init(&interface->request_list);
wl_list_init(&interface->event_list);
+ wl_list_init(&interface->enumeration_list);
wl_list_insert(ctx->protocol->interface_list.prev,
&interface->link);
ctx->interface = interface;
exit(EXIT_FAILURE);
}
- wl_list_insert(ctx->message->arg_list.prev,
- &arg->link);
+ wl_list_insert(ctx->message->arg_list.prev, &arg->link);
+ } else if (strcmp(element_name, "enum") == 0) {
+ if (name == NULL) {
+ fprintf(stderr, "no enum name given\n");
+ exit(EXIT_FAILURE);
+ }
+
+ enumeration = malloc(sizeof *enumeration);
+ enumeration->name = strdup(name);
+ enumeration->uppercase_name = uppercase_dup(name);
+ wl_list_init(&enumeration->entry_list);
+
+ wl_list_insert(ctx->interface->enumeration_list.prev,
+ &enumeration->link);
+
+ ctx->enumeration = enumeration;
+ } else if (strcmp(element_name, "entry") == 0) {
+ entry = malloc(sizeof *entry);
+ entry->name = strdup(name);
+ entry->uppercase_name = uppercase_dup(name);
+ entry->value = strdup(value);
+ wl_list_insert(ctx->enumeration->entry_list.prev,
+ &entry->link);
}
}
}
static void
+emit_enumerations(struct interface *interface)
+{
+ struct enumeration *e;
+ struct entry *entry;
+
+ wl_list_for_each(e, &interface->enumeration_list, link) {
+ printf("enum wl_%s_%s {\n", interface->name, e->name);
+ wl_list_for_each(entry, &e->entry_list, link)
+ printf("\tWL_%s_%s_%s = %s,\n",
+ interface->uppercase_name,
+ e->uppercase_name,
+ entry->uppercase_name, entry->value);
+ printf("};\n\n");
+ }
+}
+
+static void
emit_structs(struct wl_list *message_list, struct interface *interface)
{
struct message *m;
wl_list_for_each(i, &protocol->interface_list, link) {
+ emit_enumerations(i);
+
if (server) {
emit_structs(&i->request_list, i);
emit_opcodes(&i->event_list, i);
void wl_array_release(struct wl_array *array);
void *wl_array_add(struct wl_array *array, int size);
-/* FIXME: These should be part of the protocol document */
-enum wl_grab_type {
- WL_GRAB_NONE = 0,
- WL_GRAB_RESIZE_TOP = 1,
- WL_GRAB_RESIZE_BOTTOM = 2,
- WL_GRAB_RESIZE_LEFT = 4,
- WL_GRAB_RESIZE_TOP_LEFT = 5,
- WL_GRAB_RESIZE_BOTTOM_LEFT = 6,
- WL_GRAB_RESIZE_RIGHT = 8,
- WL_GRAB_RESIZE_TOP_RIGHT = 9,
- WL_GRAB_RESIZE_BOTTOM_RIGHT = 10,
- WL_GRAB_RESIZE_MASK = 15,
- WL_GRAB_MOVE = 16,
- WL_GRAB_MOTION = 17,
- WL_GRAB_DRAG = 18
-};
-
#ifdef __cplusplus
}
#endif