+ struct window *window = data;
+ uint32_t *p;
+
+ window->maximized = 0;
+ window->fullscreen = 0;
+ window->resizing = 0;
+ window->focused = 0;
+
+ wl_array_for_each(p, states) {
+ uint32_t state = *p;
+ switch (state) {
+ case XDG_SURFACE_STATE_MAXIMIZED:
+ window->maximized = 1;
+ break;
+ case XDG_SURFACE_STATE_FULLSCREEN:
+ window->fullscreen = 1;
+ break;
+ case XDG_SURFACE_STATE_RESIZING:
+ window->resizing = 1;
+ break;
+ case XDG_SURFACE_STATE_ACTIVATED:
+ window->focused = 1;
+ break;
+ default:
+ /* Unknown state */
+ break;
+ }
+ }
+
+ if (window->frame) {
+ if (window->maximized) {
+ frame_set_flag(window->frame->frame, FRAME_FLAG_MAXIMIZED);
+ } else {
+ frame_unset_flag(window->frame->frame, FRAME_FLAG_MAXIMIZED);
+ }
+
+ if (window->focused) {
+ frame_set_flag(window->frame->frame, FRAME_FLAG_ACTIVE);
+ } else {
+ frame_unset_flag(window->frame->frame, FRAME_FLAG_ACTIVE);
+ }
+ }
+
+ if (width > 0 && height > 0) {
+ /* The width / height params are for window geometry,
+ * but window_schedule_resize takes allocation. Add
+ * on the shadow margin to get the difference. */
+ int margin = window_get_shadow_margin(window);
+
+ window_schedule_resize(window,
+ width + margin * 2,
+ height + margin * 2);
+ } else {
+ window_schedule_resize(window,
+ window->saved_allocation.width,
+ window->saved_allocation.height);
+ }
+
+ xdg_surface_ack_configure(window->xdg_surface, serial);
+
+ if (window->state_changed_handler)
+ window->state_changed_handler(window, window->user_data);