Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Define the shell resize enumeration in the xml spec

  • Loading branch information...
commit 027931bd33e6bda30a701be5dd1c33f01bb8b038 1 parent 248c1b6
Kristian Høgsberg krh authored
2  compositor/compositor.c
@@ -723,7 +723,7 @@ notify_button(struct wl_input_device *device,
723 723 shell_resize(NULL,
724 724 (struct wl_shell *) &compositor->shell,
725 725 &surface->surface, device, time,
726   - WL_GRAB_RESIZE_BOTTOM_RIGHT);
  726 + WL_SHELL_RESIZE_BOTTOM_RIGHT);
727 727
728 728 if (device->grab)
729 729 device->grab->interface->button(device->grab, time,
24 compositor/shell.c
@@ -117,17 +117,17 @@ resize_grab_motion(struct wl_grab *grab,
117 117 struct wl_surface *surface = &resize->surface->surface;
118 118 int32_t width, height;
119 119
120   - if (resize->edges & WL_GRAB_RESIZE_LEFT) {
  120 + if (resize->edges & WL_SHELL_RESIZE_LEFT) {
121 121 width = device->grab_x - x + resize->width;
122   - } else if (resize->edges & WL_GRAB_RESIZE_RIGHT) {
  122 + } else if (resize->edges & WL_SHELL_RESIZE_RIGHT) {
123 123 width = x - device->grab_x + resize->width;
124 124 } else {
125 125 width = resize->width;
126 126 }
127 127
128   - if (resize->edges & WL_GRAB_RESIZE_TOP) {
  128 + if (resize->edges & WL_SHELL_RESIZE_TOP) {
129 129 height = device->grab_y - y + resize->height;
130   - } else if (resize->edges & WL_GRAB_RESIZE_BOTTOM) {
  130 + } else if (resize->edges & WL_SHELL_RESIZE_BOTTOM) {
131 131 height = y - device->grab_y + resize->height;
132 132 } else {
133 133 height = resize->height;
@@ -193,28 +193,28 @@ shell_resize(struct wl_client *client, struct wl_shell *shell,
193 193 return;
194 194
195 195 switch (edges) {
196   - case WL_GRAB_RESIZE_TOP:
  196 + case WL_SHELL_RESIZE_TOP:
197 197 pointer = WLSC_POINTER_TOP;
198 198 break;
199   - case WL_GRAB_RESIZE_BOTTOM:
  199 + case WL_SHELL_RESIZE_BOTTOM:
200 200 pointer = WLSC_POINTER_BOTTOM;
201 201 break;
202   - case WL_GRAB_RESIZE_LEFT:
  202 + case WL_SHELL_RESIZE_LEFT:
203 203 pointer = WLSC_POINTER_LEFT;
204 204 break;
205   - case WL_GRAB_RESIZE_TOP_LEFT:
  205 + case WL_SHELL_RESIZE_TOP_LEFT:
206 206 pointer = WLSC_POINTER_TOP_LEFT;
207 207 break;
208   - case WL_GRAB_RESIZE_BOTTOM_LEFT:
  208 + case WL_SHELL_RESIZE_BOTTOM_LEFT:
209 209 pointer = WLSC_POINTER_BOTTOM_LEFT;
210 210 break;
211   - case WL_GRAB_RESIZE_RIGHT:
  211 + case WL_SHELL_RESIZE_RIGHT:
212 212 pointer = WLSC_POINTER_RIGHT;
213 213 break;
214   - case WL_GRAB_RESIZE_TOP_RIGHT:
  214 + case WL_SHELL_RESIZE_TOP_RIGHT:
215 215 pointer = WLSC_POINTER_TOP_RIGHT;
216 216 break;
217   - case WL_GRAB_RESIZE_BOTTOM_RIGHT:
  217 + case WL_SHELL_RESIZE_BOTTOM_RIGHT:
218 218 pointer = WLSC_POINTER_BOTTOM_RIGHT;
219 219 break;
220 220 }
12 protocol/wayland.xml
@@ -152,6 +152,18 @@
152 152 <arg name="time" type="uint"/>
153 153 </request>
154 154
  155 + <enum name="resize">
  156 + <entry name="none" value="0"/>
  157 + <entry name="top" value="1"/>
  158 + <entry name="bottom" value="2"/>
  159 + <entry name="left" value="4"/>
  160 + <entry name="top_left" value="5"/>
  161 + <entry name="bottom_left" value="6"/>
  162 + <entry name="right" value="8"/>
  163 + <entry name="top_right" value="9"/>
  164 + <entry name="bottom_right" value="10"/>
  165 + </enum>
  166 +
155 167 <request name="resize">
156 168 <arg name="surface" type="object" interface="surface"/>
157 169 <arg name="input_device" type="object" interface="input_device"/>
68 wayland/scanner.c
@@ -68,6 +68,7 @@ struct interface {
68 68 int version;
69 69 struct wl_list request_list;
70 70 struct wl_list event_list;
  71 + struct wl_list enumeration_list;
71 72 struct wl_list link;
72 73 };
73 74
@@ -96,10 +97,25 @@ struct arg {
96 97 struct wl_list link;
97 98 };
98 99
  100 +struct enumeration {
  101 + char *name;
  102 + char *uppercase_name;
  103 + struct wl_list entry_list;
  104 + struct wl_list link;
  105 +};
  106 +
  107 +struct entry {
  108 + char *name;
  109 + char *uppercase_name;
  110 + char *value;
  111 + struct wl_list link;
  112 +};
  113 +
99 114 struct parse_context {
100 115 struct protocol *protocol;
101 116 struct interface *interface;
102 117 struct message *message;
  118 + struct enumeration *enumeration;
103 119 };
104 120
105 121 static char *
@@ -123,13 +139,16 @@ start_element(void *data, const char *element_name, const char **atts)
123 139 struct interface *interface;
124 140 struct message *message;
125 141 struct arg *arg;
126   - const char *name, *type, *interface_name;
  142 + struct enumeration *enumeration;
  143 + struct entry *entry;
  144 + const char *name, *type, *interface_name, *value;
127 145 int i, version;
128 146
129 147 name = NULL;
130 148 type = NULL;
131 149 version = 0;
132 150 interface_name = NULL;
  151 + value = NULL;
133 152 for (i = 0; atts[i]; i += 2) {
134 153 if (strcmp(atts[i], "name") == 0)
135 154 name = atts[i + 1];
@@ -137,6 +156,8 @@ start_element(void *data, const char *element_name, const char **atts)
137 156 version = atoi(atts[i + 1]);
138 157 if (strcmp(atts[i], "type") == 0)
139 158 type = atts[i + 1];
  159 + if (strcmp(atts[i], "value") == 0)
  160 + value = atts[i + 1];
140 161 if (strcmp(atts[i], "interface") == 0)
141 162 interface_name = atts[i + 1];
142 163 }
@@ -166,6 +187,7 @@ start_element(void *data, const char *element_name, const char **atts)
166 187 interface->version = version;
167 188 wl_list_init(&interface->request_list);
168 189 wl_list_init(&interface->event_list);
  190 + wl_list_init(&interface->enumeration_list);
169 191 wl_list_insert(ctx->protocol->interface_list.prev,
170 192 &interface->link);
171 193 ctx->interface = interface;
@@ -227,8 +249,29 @@ start_element(void *data, const char *element_name, const char **atts)
227 249 exit(EXIT_FAILURE);
228 250 }
229 251
230   - wl_list_insert(ctx->message->arg_list.prev,
231   - &arg->link);
  252 + wl_list_insert(ctx->message->arg_list.prev, &arg->link);
  253 + } else if (strcmp(element_name, "enum") == 0) {
  254 + if (name == NULL) {
  255 + fprintf(stderr, "no enum name given\n");
  256 + exit(EXIT_FAILURE);
  257 + }
  258 +
  259 + enumeration = malloc(sizeof *enumeration);
  260 + enumeration->name = strdup(name);
  261 + enumeration->uppercase_name = uppercase_dup(name);
  262 + wl_list_init(&enumeration->entry_list);
  263 +
  264 + wl_list_insert(ctx->interface->enumeration_list.prev,
  265 + &enumeration->link);
  266 +
  267 + ctx->enumeration = enumeration;
  268 + } else if (strcmp(element_name, "entry") == 0) {
  269 + entry = malloc(sizeof *entry);
  270 + entry->name = strdup(name);
  271 + entry->uppercase_name = uppercase_dup(name);
  272 + entry->value = strdup(value);
  273 + wl_list_insert(ctx->enumeration->entry_list.prev,
  274 + &entry->link);
232 275 }
233 276 }
234 277
@@ -421,6 +464,23 @@ static const char *indent(int n)
421 464 }
422 465
423 466 static void
  467 +emit_enumerations(struct interface *interface)
  468 +{
  469 + struct enumeration *e;
  470 + struct entry *entry;
  471 +
  472 + wl_list_for_each(e, &interface->enumeration_list, link) {
  473 + printf("enum wl_%s_%s {\n", interface->name, e->name);
  474 + wl_list_for_each(entry, &e->entry_list, link)
  475 + printf("\tWL_%s_%s_%s = %s,\n",
  476 + interface->uppercase_name,
  477 + e->uppercase_name,
  478 + entry->uppercase_name, entry->value);
  479 + printf("};\n\n");
  480 + }
  481 +}
  482 +
  483 +static void
424 484 emit_structs(struct wl_list *message_list, struct interface *interface)
425 485 {
426 486 struct message *m;
@@ -543,6 +603,8 @@ emit_header(struct protocol *protocol, int server)
543 603
544 604 wl_list_for_each(i, &protocol->interface_list, link) {
545 605
  606 + emit_enumerations(i);
  607 +
546 608 if (server) {
547 609 emit_structs(&i->request_list, i);
548 610 emit_opcodes(&i->event_list, i);
17 wayland/wayland-util.h
@@ -149,23 +149,6 @@ void wl_array_init(struct wl_array *array);
149 149 void wl_array_release(struct wl_array *array);
150 150 void *wl_array_add(struct wl_array *array, int size);
151 151
152   -/* FIXME: These should be part of the protocol document */
153   -enum wl_grab_type {
154   - WL_GRAB_NONE = 0,
155   - WL_GRAB_RESIZE_TOP = 1,
156   - WL_GRAB_RESIZE_BOTTOM = 2,
157   - WL_GRAB_RESIZE_LEFT = 4,
158   - WL_GRAB_RESIZE_TOP_LEFT = 5,
159   - WL_GRAB_RESIZE_BOTTOM_LEFT = 6,
160   - WL_GRAB_RESIZE_RIGHT = 8,
161   - WL_GRAB_RESIZE_TOP_RIGHT = 9,
162   - WL_GRAB_RESIZE_BOTTOM_RIGHT = 10,
163   - WL_GRAB_RESIZE_MASK = 15,
164   - WL_GRAB_MOVE = 16,
165   - WL_GRAB_MOTION = 17,
166   - WL_GRAB_DRAG = 18
167   -};
168   -
169 152 #ifdef __cplusplus
170 153 }
171 154 #endif

0 comments on commit 027931b

Please sign in to comment.
Something went wrong with that request. Please try again.