mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-07 13:29:55 -05:00
Define the shell resize enumeration in the xml spec
This commit is contained in:
parent
248c1b61ce
commit
027931bd33
5 changed files with 90 additions and 33 deletions
|
|
@ -723,7 +723,7 @@ notify_button(struct wl_input_device *device,
|
||||||
shell_resize(NULL,
|
shell_resize(NULL,
|
||||||
(struct wl_shell *) &compositor->shell,
|
(struct wl_shell *) &compositor->shell,
|
||||||
&surface->surface, device, time,
|
&surface->surface, device, time,
|
||||||
WL_GRAB_RESIZE_BOTTOM_RIGHT);
|
WL_SHELL_RESIZE_BOTTOM_RIGHT);
|
||||||
|
|
||||||
if (device->grab)
|
if (device->grab)
|
||||||
device->grab->interface->button(device->grab, time,
|
device->grab->interface->button(device->grab, time,
|
||||||
|
|
|
||||||
|
|
@ -117,17 +117,17 @@ resize_grab_motion(struct wl_grab *grab,
|
||||||
struct wl_surface *surface = &resize->surface->surface;
|
struct wl_surface *surface = &resize->surface->surface;
|
||||||
int32_t width, height;
|
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;
|
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;
|
width = x - device->grab_x + resize->width;
|
||||||
} else {
|
} else {
|
||||||
width = resize->width;
|
width = resize->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resize->edges & WL_GRAB_RESIZE_TOP) {
|
if (resize->edges & WL_SHELL_RESIZE_TOP) {
|
||||||
height = device->grab_y - y + resize->height;
|
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;
|
height = y - device->grab_y + resize->height;
|
||||||
} else {
|
} else {
|
||||||
height = resize->height;
|
height = resize->height;
|
||||||
|
|
@ -193,28 +193,28 @@ shell_resize(struct wl_client *client, struct wl_shell *shell,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (edges) {
|
switch (edges) {
|
||||||
case WL_GRAB_RESIZE_TOP:
|
case WL_SHELL_RESIZE_TOP:
|
||||||
pointer = WLSC_POINTER_TOP;
|
pointer = WLSC_POINTER_TOP;
|
||||||
break;
|
break;
|
||||||
case WL_GRAB_RESIZE_BOTTOM:
|
case WL_SHELL_RESIZE_BOTTOM:
|
||||||
pointer = WLSC_POINTER_BOTTOM;
|
pointer = WLSC_POINTER_BOTTOM;
|
||||||
break;
|
break;
|
||||||
case WL_GRAB_RESIZE_LEFT:
|
case WL_SHELL_RESIZE_LEFT:
|
||||||
pointer = WLSC_POINTER_LEFT;
|
pointer = WLSC_POINTER_LEFT;
|
||||||
break;
|
break;
|
||||||
case WL_GRAB_RESIZE_TOP_LEFT:
|
case WL_SHELL_RESIZE_TOP_LEFT:
|
||||||
pointer = WLSC_POINTER_TOP_LEFT;
|
pointer = WLSC_POINTER_TOP_LEFT;
|
||||||
break;
|
break;
|
||||||
case WL_GRAB_RESIZE_BOTTOM_LEFT:
|
case WL_SHELL_RESIZE_BOTTOM_LEFT:
|
||||||
pointer = WLSC_POINTER_BOTTOM_LEFT;
|
pointer = WLSC_POINTER_BOTTOM_LEFT;
|
||||||
break;
|
break;
|
||||||
case WL_GRAB_RESIZE_RIGHT:
|
case WL_SHELL_RESIZE_RIGHT:
|
||||||
pointer = WLSC_POINTER_RIGHT;
|
pointer = WLSC_POINTER_RIGHT;
|
||||||
break;
|
break;
|
||||||
case WL_GRAB_RESIZE_TOP_RIGHT:
|
case WL_SHELL_RESIZE_TOP_RIGHT:
|
||||||
pointer = WLSC_POINTER_TOP_RIGHT;
|
pointer = WLSC_POINTER_TOP_RIGHT;
|
||||||
break;
|
break;
|
||||||
case WL_GRAB_RESIZE_BOTTOM_RIGHT:
|
case WL_SHELL_RESIZE_BOTTOM_RIGHT:
|
||||||
pointer = WLSC_POINTER_BOTTOM_RIGHT;
|
pointer = WLSC_POINTER_BOTTOM_RIGHT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,18 @@
|
||||||
<arg name="time" type="uint"/>
|
<arg name="time" type="uint"/>
|
||||||
</request>
|
</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">
|
<request name="resize">
|
||||||
<arg name="surface" type="object" interface="surface"/>
|
<arg name="surface" type="object" interface="surface"/>
|
||||||
<arg name="input_device" type="object" interface="input_device"/>
|
<arg name="input_device" type="object" interface="input_device"/>
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ struct interface {
|
||||||
int version;
|
int version;
|
||||||
struct wl_list request_list;
|
struct wl_list request_list;
|
||||||
struct wl_list event_list;
|
struct wl_list event_list;
|
||||||
|
struct wl_list enumeration_list;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -96,10 +97,25 @@ struct arg {
|
||||||
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 parse_context {
|
||||||
struct protocol *protocol;
|
struct protocol *protocol;
|
||||||
struct interface *interface;
|
struct interface *interface;
|
||||||
struct message *message;
|
struct message *message;
|
||||||
|
struct enumeration *enumeration;
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
|
@ -123,13 +139,16 @@ start_element(void *data, const char *element_name, const char **atts)
|
||||||
struct interface *interface;
|
struct interface *interface;
|
||||||
struct message *message;
|
struct message *message;
|
||||||
struct arg *arg;
|
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;
|
int i, version;
|
||||||
|
|
||||||
name = NULL;
|
name = NULL;
|
||||||
type = NULL;
|
type = NULL;
|
||||||
version = 0;
|
version = 0;
|
||||||
interface_name = NULL;
|
interface_name = NULL;
|
||||||
|
value = NULL;
|
||||||
for (i = 0; atts[i]; i += 2) {
|
for (i = 0; atts[i]; i += 2) {
|
||||||
if (strcmp(atts[i], "name") == 0)
|
if (strcmp(atts[i], "name") == 0)
|
||||||
name = atts[i + 1];
|
name = atts[i + 1];
|
||||||
|
|
@ -137,6 +156,8 @@ start_element(void *data, const char *element_name, const char **atts)
|
||||||
version = atoi(atts[i + 1]);
|
version = atoi(atts[i + 1]);
|
||||||
if (strcmp(atts[i], "type") == 0)
|
if (strcmp(atts[i], "type") == 0)
|
||||||
type = atts[i + 1];
|
type = atts[i + 1];
|
||||||
|
if (strcmp(atts[i], "value") == 0)
|
||||||
|
value = atts[i + 1];
|
||||||
if (strcmp(atts[i], "interface") == 0)
|
if (strcmp(atts[i], "interface") == 0)
|
||||||
interface_name = atts[i + 1];
|
interface_name = atts[i + 1];
|
||||||
}
|
}
|
||||||
|
|
@ -166,6 +187,7 @@ start_element(void *data, const char *element_name, const char **atts)
|
||||||
interface->version = version;
|
interface->version = version;
|
||||||
wl_list_init(&interface->request_list);
|
wl_list_init(&interface->request_list);
|
||||||
wl_list_init(&interface->event_list);
|
wl_list_init(&interface->event_list);
|
||||||
|
wl_list_init(&interface->enumeration_list);
|
||||||
wl_list_insert(ctx->protocol->interface_list.prev,
|
wl_list_insert(ctx->protocol->interface_list.prev,
|
||||||
&interface->link);
|
&interface->link);
|
||||||
ctx->interface = interface;
|
ctx->interface = interface;
|
||||||
|
|
@ -227,8 +249,29 @@ start_element(void *data, const char *element_name, const char **atts)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_list_insert(ctx->message->arg_list.prev,
|
wl_list_insert(ctx->message->arg_list.prev, &arg->link);
|
||||||
&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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -420,6 +463,23 @@ static const char *indent(int n)
|
||||||
return whitespace[n % 8] + 12 - n / 8;
|
return whitespace[n % 8] + 12 - n / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
emit_structs(struct wl_list *message_list, struct interface *interface)
|
emit_structs(struct wl_list *message_list, struct interface *interface)
|
||||||
{
|
{
|
||||||
|
|
@ -543,6 +603,8 @@ emit_header(struct protocol *protocol, int server)
|
||||||
|
|
||||||
wl_list_for_each(i, &protocol->interface_list, link) {
|
wl_list_for_each(i, &protocol->interface_list, link) {
|
||||||
|
|
||||||
|
emit_enumerations(i);
|
||||||
|
|
||||||
if (server) {
|
if (server) {
|
||||||
emit_structs(&i->request_list, i);
|
emit_structs(&i->request_list, i);
|
||||||
emit_opcodes(&i->event_list, i);
|
emit_opcodes(&i->event_list, i);
|
||||||
|
|
|
||||||
|
|
@ -149,23 +149,6 @@ void wl_array_init(struct wl_array *array);
|
||||||
void wl_array_release(struct wl_array *array);
|
void wl_array_release(struct wl_array *array);
|
||||||
void *wl_array_add(struct wl_array *array, int size);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue