2 * Copyright © 2013 Jason Ekstrand
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 #include "compositor.h"
37 #include "fullscreen-shell-unstable-v1-server-protocol.h"
38 #include "shared/helpers.h"
40 struct fullscreen_shell {
41 struct wl_client *client;
42 struct wl_listener client_destroyed;
43 struct weston_compositor *compositor;
45 struct weston_layer layer;
46 struct wl_list output_list;
47 struct wl_listener output_created_listener;
49 struct wl_listener seat_created_listener;
51 /* List of one surface per client, presented for the NULL output
53 * This is implemented as a list in case someone fixes the shell
54 * implementation to support more than one client.
56 struct wl_list default_surface_list; /* struct fs_client_surface::link */
60 struct fullscreen_shell *shell;
63 struct weston_output *output;
64 struct wl_listener output_destroyed;
67 struct weston_surface *surface;
68 struct wl_listener surface_destroyed;
69 struct wl_resource *mode_feedback;
71 int presented_for_mode;
72 enum zwp_fullscreen_shell_v1_present_method method;
76 struct weston_surface *surface;
77 struct wl_listener surface_destroyed;
78 struct weston_view *view;
79 struct weston_view *black_view;
80 struct weston_transform transform; /* matrix from x, y */
82 int presented_for_mode;
83 enum zwp_fullscreen_shell_v1_present_method method;
87 struct pointer_focus_listener {
88 struct fullscreen_shell *shell;
89 struct wl_listener pointer_focus;
90 struct wl_listener seat_caps;
91 struct wl_listener seat_destroyed;
94 struct fs_client_surface {
95 struct weston_surface *surface;
96 enum zwp_fullscreen_shell_v1_present_method method;
97 struct wl_list link; /* struct fullscreen_shell::default_surface_list */
98 struct wl_listener surface_destroyed;
102 remove_default_surface(struct fs_client_surface *surf)
104 wl_list_remove(&surf->surface_destroyed.link);
105 wl_list_remove(&surf->link);
110 default_surface_destroy_listener(struct wl_listener *listener, void *data)
112 struct fs_client_surface *surf;
114 surf = container_of(listener, struct fs_client_surface, surface_destroyed);
116 remove_default_surface(surf);
120 replace_default_surface(struct fullscreen_shell *shell, struct weston_surface *surface,
121 enum zwp_fullscreen_shell_v1_present_method method)
123 struct fs_client_surface *surf, *prev = NULL;
125 if (!wl_list_empty(&shell->default_surface_list))
126 prev = container_of(shell->default_surface_list.prev,
127 struct fs_client_surface, link);
129 surf = zalloc(sizeof *surf);
133 surf->surface = surface;
134 surf->method = method;
137 remove_default_surface(prev);
139 wl_list_insert(shell->default_surface_list.prev, &surf->link);
141 surf->surface_destroyed.notify = default_surface_destroy_listener;
142 wl_signal_add(&surface->destroy_signal, &surf->surface_destroyed);
146 pointer_focus_changed(struct wl_listener *listener, void *data)
148 struct weston_pointer *pointer = data;
150 if (pointer->focus && pointer->focus->surface->resource)
151 weston_seat_set_keyboard_focus(pointer->seat, pointer->focus->surface);
155 seat_caps_changed(struct wl_listener *l, void *data)
157 struct weston_seat *seat = data;
158 struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
159 struct weston_pointer *pointer = weston_seat_get_pointer(seat);
160 struct pointer_focus_listener *listener;
161 struct fs_output *fsout;
163 listener = container_of(l, struct pointer_focus_listener, seat_caps);
167 if (!listener->pointer_focus.link.prev) {
168 wl_signal_add(&pointer->focus_signal,
169 &listener->pointer_focus);
172 if (listener->pointer_focus.link.prev) {
173 wl_list_remove(&listener->pointer_focus.link);
177 if (keyboard && keyboard->focus != NULL) {
178 wl_list_for_each(fsout, &listener->shell->output_list, link) {
179 if (fsout->surface) {
180 weston_seat_set_keyboard_focus(seat, fsout->surface);
188 seat_destroyed(struct wl_listener *l, void *data)
190 struct pointer_focus_listener *listener;
192 listener = container_of(l, struct pointer_focus_listener,
199 seat_created(struct wl_listener *l, void *data)
201 struct weston_seat *seat = data;
202 struct pointer_focus_listener *listener;
204 listener = zalloc(sizeof *listener);
208 listener->shell = container_of(l, struct fullscreen_shell,
209 seat_created_listener);
210 listener->pointer_focus.notify = pointer_focus_changed;
211 listener->seat_caps.notify = seat_caps_changed;
212 listener->seat_destroyed.notify = seat_destroyed;
214 wl_signal_add(&seat->destroy_signal, &listener->seat_destroyed);
215 wl_signal_add(&seat->updated_caps_signal, &listener->seat_caps);
217 seat_caps_changed(&listener->seat_caps, seat);
221 black_surface_committed(struct weston_surface *es, int32_t sx, int32_t sy)
225 static struct weston_view *
226 create_black_surface(struct weston_compositor *ec, struct fs_output *fsout,
227 float x, float y, int w, int h)
229 struct weston_surface *surface = NULL;
230 struct weston_view *view;
232 surface = weston_surface_create(ec);
233 if (surface == NULL) {
234 weston_log("no memory\n");
237 view = weston_view_create(surface);
239 weston_surface_destroy(surface);
240 weston_log("no memory\n");
244 surface->committed = black_surface_committed;
245 surface->committed_private = fsout;
246 weston_surface_set_color(surface, 0.0f, 0.0f, 0.0f, 1.0f);
247 pixman_region32_fini(&surface->opaque);
248 pixman_region32_init_rect(&surface->opaque, 0, 0, w, h);
249 pixman_region32_fini(&surface->input);
250 pixman_region32_init_rect(&surface->input, 0, 0, w, h);
252 weston_surface_set_size(surface, w, h);
253 weston_view_set_position(view, x, y);
259 fs_output_set_surface(struct fs_output *fsout, struct weston_surface *surface,
260 enum zwp_fullscreen_shell_v1_present_method method,
261 int32_t framerate, int presented_for_mode);
263 fs_output_apply_pending(struct fs_output *fsout);
265 fs_output_clear_pending(struct fs_output *fsout);
268 fs_output_destroy(struct fs_output *fsout)
270 fs_output_set_surface(fsout, NULL, 0, 0, 0);
271 fs_output_clear_pending(fsout);
273 wl_list_remove(&fsout->link);
276 wl_list_remove(&fsout->output_destroyed.link);
280 output_destroyed(struct wl_listener *listener, void *data)
282 struct fs_output *output = container_of(listener,
285 fs_output_destroy(output);
289 surface_destroyed(struct wl_listener *listener, void *data)
291 struct fs_output *fsout = container_of(listener,
294 fsout->surface = NULL;
299 pending_surface_destroyed(struct wl_listener *listener, void *data)
301 struct fs_output *fsout = container_of(listener,
303 pending.surface_destroyed);
304 fsout->pending.surface = NULL;
308 configure_presented_surface(struct weston_surface *surface, int32_t sx,
311 static struct fs_output *
312 fs_output_create(struct fullscreen_shell *shell, struct weston_output *output)
314 struct fs_output *fsout;
315 struct fs_client_surface *surf;
317 fsout = zalloc(sizeof *fsout);
321 fsout->shell = shell;
322 wl_list_insert(&shell->output_list, &fsout->link);
324 fsout->output = output;
325 fsout->output_destroyed.notify = output_destroyed;
326 wl_signal_add(&output->destroy_signal, &fsout->output_destroyed);
328 fsout->surface_destroyed.notify = surface_destroyed;
329 fsout->pending.surface_destroyed.notify = pending_surface_destroyed;
330 fsout->black_view = create_black_surface(shell->compositor, fsout,
331 output->x, output->y,
332 output->width, output->height);
333 fsout->black_view->surface->is_mapped = true;
334 fsout->black_view->is_mapped = true;
335 weston_layer_entry_insert(&shell->layer.view_list,
336 &fsout->black_view->layer_link);
337 wl_list_init(&fsout->transform.link);
339 if (!wl_list_empty(&shell->default_surface_list)) {
340 surf = container_of(shell->default_surface_list.prev,
341 struct fs_client_surface, link);
343 fs_output_set_surface(fsout, surf->surface, surf->method, 0, 0);
344 configure_presented_surface(surf->surface, 0, 0);
350 static struct fs_output *
351 fs_output_for_output(struct weston_output *output)
353 struct wl_listener *listener;
358 listener = wl_signal_get(&output->destroy_signal, output_destroyed);
360 return container_of(listener, struct fs_output, output_destroyed);
364 restore_output_mode(struct weston_output *output)
366 if (output && output->original_mode)
367 weston_output_mode_switch_to_native(output);
371 * Returns the bounding box of a surface and all its sub-surfaces,
372 * in surface-local coordinates. */
374 surface_subsurfaces_boundingbox(struct weston_surface *surface, int32_t *x,
375 int32_t *y, int32_t *w, int32_t *h) {
376 pixman_region32_t region;
378 struct weston_subsurface *subsurface;
380 pixman_region32_init_rect(®ion, 0, 0,
384 wl_list_for_each(subsurface, &surface->subsurface_list, parent_link) {
385 pixman_region32_union_rect(®ion, ®ion,
386 subsurface->position.x,
387 subsurface->position.y,
388 subsurface->surface->width,
389 subsurface->surface->height);
392 box = pixman_region32_extents(®ion);
398 *w = box->x2 - box->x1;
400 *h = box->y2 - box->y1;
402 pixman_region32_fini(®ion);
406 fs_output_center_view(struct fs_output *fsout)
408 int32_t surf_x, surf_y, surf_width, surf_height;
410 struct weston_output *output = fsout->output;
412 surface_subsurfaces_boundingbox(fsout->view->surface, &surf_x, &surf_y,
413 &surf_width, &surf_height);
415 x = output->x + (output->width - surf_width) / 2 - surf_x / 2;
416 y = output->y + (output->height - surf_height) / 2 - surf_y / 2;
418 weston_view_set_position(fsout->view, x, y);
422 fs_output_scale_view(struct fs_output *fsout, float width, float height)
425 int32_t surf_x, surf_y, surf_width, surf_height;
426 struct weston_matrix *matrix;
427 struct weston_view *view = fsout->view;
428 struct weston_output *output = fsout->output;
430 surface_subsurfaces_boundingbox(view->surface, &surf_x, &surf_y,
431 &surf_width, &surf_height);
433 if (output->width == surf_width && output->height == surf_height) {
434 weston_view_set_position(view,
435 fsout->output->x - surf_x,
436 fsout->output->y - surf_y);
438 matrix = &fsout->transform.matrix;
439 weston_matrix_init(matrix);
441 weston_matrix_scale(matrix, width / surf_width,
442 height / surf_height, 1);
443 wl_list_remove(&fsout->transform.link);
444 wl_list_insert(&fsout->view->geometry.transformation_list,
445 &fsout->transform.link);
447 x = output->x + (output->width - width) / 2 - surf_x;
448 y = output->y + (output->height - height) / 2 - surf_y;
450 weston_view_set_position(view, x, y);
455 fs_output_configure(struct fs_output *fsout, struct weston_surface *surface);
458 fs_output_configure_simple(struct fs_output *fsout,
459 struct weston_surface *configured_surface)
461 struct weston_output *output = fsout->output;
462 float output_aspect, surface_aspect;
463 int32_t surf_x, surf_y, surf_width, surf_height;
465 if (fsout->pending.surface == configured_surface)
466 fs_output_apply_pending(fsout);
470 restore_output_mode(fsout->output);
472 wl_list_remove(&fsout->transform.link);
473 wl_list_init(&fsout->transform.link);
475 surface_subsurfaces_boundingbox(fsout->view->surface,
477 &surf_width, &surf_height);
479 output_aspect = (float) output->width / (float) output->height;
480 surface_aspect = (float) surf_width / (float) surf_height;
482 switch (fsout->method) {
483 case ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_DEFAULT:
484 case ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_CENTER:
485 fs_output_center_view(fsout);
488 case ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_ZOOM:
489 if (output_aspect < surface_aspect)
490 fs_output_scale_view(fsout,
492 output->width / surface_aspect);
494 fs_output_scale_view(fsout,
495 output->height * surface_aspect,
499 case ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_ZOOM_CROP:
500 if (output_aspect < surface_aspect)
501 fs_output_scale_view(fsout,
502 output->height * surface_aspect,
505 fs_output_scale_view(fsout,
507 output->width / surface_aspect);
510 case ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_STRETCH:
511 fs_output_scale_view(fsout, output->width, output->height);
517 weston_view_set_position(fsout->black_view,
518 fsout->output->x - surf_x,
519 fsout->output->y - surf_y);
520 weston_surface_set_size(fsout->black_view->surface,
521 fsout->output->width,
522 fsout->output->height);
526 fs_output_configure_for_mode(struct fs_output *fsout,
527 struct weston_surface *configured_surface)
529 int32_t surf_x, surf_y, surf_width, surf_height;
530 struct weston_mode mode;
533 if (fsout->pending.surface != configured_surface) {
534 /* Nothing to really reconfigure. We'll just recenter the
535 * view in case they played with subsurfaces */
536 fs_output_center_view(fsout);
540 /* We have a pending surface */
541 surface_subsurfaces_boundingbox(fsout->pending.surface,
543 &surf_width, &surf_height);
545 /* The actual output mode is in physical units. We need to
546 * transform the surface size to physical unit size by flipping ans
547 * possibly scaling it.
549 switch (fsout->output->transform) {
550 case WL_OUTPUT_TRANSFORM_90:
551 case WL_OUTPUT_TRANSFORM_FLIPPED_90:
552 case WL_OUTPUT_TRANSFORM_270:
553 case WL_OUTPUT_TRANSFORM_FLIPPED_270:
554 mode.width = surf_height * fsout->output->native_scale;
555 mode.height = surf_width * fsout->output->native_scale;
558 case WL_OUTPUT_TRANSFORM_NORMAL:
559 case WL_OUTPUT_TRANSFORM_FLIPPED:
560 case WL_OUTPUT_TRANSFORM_180:
561 case WL_OUTPUT_TRANSFORM_FLIPPED_180:
563 mode.width = surf_width * fsout->output->native_scale;
564 mode.height = surf_height * fsout->output->native_scale;
567 mode.refresh = fsout->pending.framerate;
569 ret = weston_output_mode_switch_to_temporary(fsout->output, &mode,
570 fsout->output->native_scale);
573 /* The mode switch failed. Clear the pending and
574 * reconfigure as per normal */
575 if (fsout->pending.mode_feedback) {
576 zwp_fullscreen_shell_mode_feedback_v1_send_mode_failed(
577 fsout->pending.mode_feedback);
578 wl_resource_destroy(fsout->pending.mode_feedback);
579 fsout->pending.mode_feedback = NULL;
582 fs_output_clear_pending(fsout);
586 if (fsout->pending.mode_feedback) {
587 zwp_fullscreen_shell_mode_feedback_v1_send_mode_successful(
588 fsout->pending.mode_feedback);
589 wl_resource_destroy(fsout->pending.mode_feedback);
590 fsout->pending.mode_feedback = NULL;
593 fs_output_apply_pending(fsout);
595 weston_view_set_position(fsout->view,
596 fsout->output->x - surf_x,
597 fsout->output->y - surf_y);
601 fs_output_configure(struct fs_output *fsout,
602 struct weston_surface *surface)
604 if (fsout->pending.surface == surface) {
605 if (fsout->pending.presented_for_mode)
606 fs_output_configure_for_mode(fsout, surface);
608 fs_output_configure_simple(fsout, surface);
610 if (fsout->presented_for_mode)
611 fs_output_configure_for_mode(fsout, surface);
613 fs_output_configure_simple(fsout, surface);
616 weston_output_schedule_repaint(fsout->output);
620 configure_presented_surface(struct weston_surface *surface, int32_t sx,
623 struct fullscreen_shell *shell = surface->committed_private;
624 struct fs_output *fsout;
626 if (surface->committed != configure_presented_surface)
629 wl_list_for_each(fsout, &shell->output_list, link)
630 if (fsout->surface == surface ||
631 fsout->pending.surface == surface)
632 fs_output_configure(fsout, surface);
636 fs_output_apply_pending(struct fs_output *fsout)
638 assert(fsout->pending.surface);
640 if (fsout->surface && fsout->surface != fsout->pending.surface) {
641 wl_list_remove(&fsout->surface_destroyed.link);
643 weston_view_destroy(fsout->view);
646 if (wl_list_empty(&fsout->surface->views)) {
647 fsout->surface->committed = NULL;
648 fsout->surface->committed_private = NULL;
651 fsout->surface = NULL;
654 fsout->method = fsout->pending.method;
655 fsout->framerate = fsout->pending.framerate;
656 fsout->presented_for_mode = fsout->pending.presented_for_mode;
658 if (fsout->surface != fsout->pending.surface) {
659 fsout->surface = fsout->pending.surface;
661 fsout->view = weston_view_create(fsout->surface);
663 weston_log("no memory\n");
666 fsout->view->is_mapped = true;
668 wl_signal_add(&fsout->surface->destroy_signal,
669 &fsout->surface_destroyed);
670 weston_layer_entry_insert(&fsout->shell->layer.view_list,
671 &fsout->view->layer_link);
674 fs_output_clear_pending(fsout);
678 fs_output_clear_pending(struct fs_output *fsout)
680 if (!fsout->pending.surface)
683 if (fsout->pending.mode_feedback) {
684 zwp_fullscreen_shell_mode_feedback_v1_send_present_cancelled(
685 fsout->pending.mode_feedback);
686 wl_resource_destroy(fsout->pending.mode_feedback);
687 fsout->pending.mode_feedback = NULL;
690 wl_list_remove(&fsout->pending.surface_destroyed.link);
691 fsout->pending.surface = NULL;
695 fs_output_set_surface(struct fs_output *fsout, struct weston_surface *surface,
696 enum zwp_fullscreen_shell_v1_present_method method,
697 int32_t framerate, int presented_for_mode)
699 fs_output_clear_pending(fsout);
702 if (!surface->committed) {
703 surface->committed = configure_presented_surface;
704 surface->committed_private = fsout->shell;
707 fsout->pending.surface = surface;
708 wl_signal_add(&fsout->pending.surface->destroy_signal,
709 &fsout->pending.surface_destroyed);
711 fsout->pending.method = method;
712 fsout->pending.framerate = framerate;
713 fsout->pending.presented_for_mode = presented_for_mode;
714 } else if (fsout->surface) {
715 /* we clear immediately */
716 wl_list_remove(&fsout->surface_destroyed.link);
718 weston_view_destroy(fsout->view);
721 if (wl_list_empty(&fsout->surface->views)) {
722 fsout->surface->committed = NULL;
723 fsout->surface->committed_private = NULL;
726 fsout->surface = NULL;
728 weston_output_schedule_repaint(fsout->output);
733 fullscreen_shell_release(struct wl_client *client,
734 struct wl_resource *resource)
736 wl_resource_destroy(resource);
740 fullscreen_shell_present_surface(struct wl_client *client,
741 struct wl_resource *resource,
742 struct wl_resource *surface_res,
744 struct wl_resource *output_res)
746 struct fullscreen_shell *shell =
747 wl_resource_get_user_data(resource);
748 struct weston_output *output;
749 struct weston_surface *surface;
750 struct weston_seat *seat;
751 struct fs_output *fsout;
753 surface = surface_res ? wl_resource_get_user_data(surface_res) : NULL;
756 case ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_DEFAULT:
757 case ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_CENTER:
758 case ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_ZOOM:
759 case ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_ZOOM_CROP:
760 case ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_STRETCH:
763 wl_resource_post_error(resource,
764 ZWP_FULLSCREEN_SHELL_V1_ERROR_INVALID_METHOD,
765 "Invalid presentation method");
769 output = wl_resource_get_user_data(output_res);
770 fsout = fs_output_for_output(output);
771 fs_output_set_surface(fsout, surface, method, 0, 0);
773 replace_default_surface(shell, surface, method);
775 wl_list_for_each(fsout, &shell->output_list, link)
776 fs_output_set_surface(fsout, surface, method, 0, 0);
780 wl_list_for_each(seat, &shell->compositor->seat_list, link) {
781 struct weston_keyboard *keyboard =
782 weston_seat_get_keyboard(seat);
784 if (keyboard && !keyboard->focus)
785 weston_seat_set_keyboard_focus(seat, surface);
791 mode_feedback_destroyed(struct wl_resource *resource)
793 struct fs_output *fsout = wl_resource_get_user_data(resource);
795 fsout->pending.mode_feedback = NULL;
799 fullscreen_shell_present_surface_for_mode(struct wl_client *client,
800 struct wl_resource *resource,
801 struct wl_resource *surface_res,
802 struct wl_resource *output_res,
804 uint32_t feedback_id)
806 struct fullscreen_shell *shell =
807 wl_resource_get_user_data(resource);
808 struct weston_output *output;
809 struct weston_surface *surface;
810 struct weston_seat *seat;
811 struct fs_output *fsout;
813 output = wl_resource_get_user_data(output_res);
814 fsout = fs_output_for_output(output);
816 if (surface_res == NULL) {
817 fs_output_set_surface(fsout, NULL, 0, 0, 0);
821 surface = wl_resource_get_user_data(surface_res);
822 fs_output_set_surface(fsout, surface, 0, framerate, 1);
824 fsout->pending.mode_feedback =
825 wl_resource_create(client,
826 &zwp_fullscreen_shell_mode_feedback_v1_interface,
828 wl_resource_set_implementation(fsout->pending.mode_feedback, NULL,
829 fsout, mode_feedback_destroyed);
831 wl_list_for_each(seat, &shell->compositor->seat_list, link) {
832 struct weston_keyboard *keyboard =
833 weston_seat_get_keyboard(seat);
835 if (keyboard && !keyboard->focus)
836 weston_seat_set_keyboard_focus(seat, surface);
840 struct zwp_fullscreen_shell_v1_interface fullscreen_shell_implementation = {
841 fullscreen_shell_release,
842 fullscreen_shell_present_surface,
843 fullscreen_shell_present_surface_for_mode,
847 output_created(struct wl_listener *listener, void *data)
849 struct fullscreen_shell *shell;
851 shell = container_of(listener, struct fullscreen_shell,
852 output_created_listener);
854 fs_output_create(shell, data);
858 client_destroyed(struct wl_listener *listener, void *data)
860 struct fullscreen_shell *shell = container_of(listener,
861 struct fullscreen_shell,
863 shell->client = NULL;
867 bind_fullscreen_shell(struct wl_client *client, void *data, uint32_t version,
870 struct fullscreen_shell *shell = data;
871 struct wl_resource *resource;
873 if (shell->client != NULL && shell->client != client)
875 else if (shell->client == NULL) {
876 shell->client = client;
877 wl_client_add_destroy_listener(client, &shell->client_destroyed);
880 resource = wl_resource_create(client,
881 &zwp_fullscreen_shell_v1_interface,
883 wl_resource_set_implementation(resource,
884 &fullscreen_shell_implementation,
887 if (shell->compositor->capabilities & WESTON_CAP_CURSOR_PLANE)
888 zwp_fullscreen_shell_v1_send_capability(resource,
889 ZWP_FULLSCREEN_SHELL_V1_CAPABILITY_CURSOR_PLANE);
891 if (shell->compositor->capabilities & WESTON_CAP_ARBITRARY_MODES)
892 zwp_fullscreen_shell_v1_send_capability(resource,
893 ZWP_FULLSCREEN_SHELL_V1_CAPABILITY_ARBITRARY_MODES);
897 module_init(struct weston_compositor *compositor,
898 int *argc, char *argv[])
900 struct fullscreen_shell *shell;
901 struct weston_seat *seat;
902 struct weston_output *output;
904 shell = zalloc(sizeof *shell);
908 shell->compositor = compositor;
909 wl_list_init(&shell->default_surface_list);
911 shell->client_destroyed.notify = client_destroyed;
913 weston_layer_init(&shell->layer, &compositor->cursor_layer.link);
915 wl_list_init(&shell->output_list);
916 shell->output_created_listener.notify = output_created;
917 wl_signal_add(&compositor->output_created_signal,
918 &shell->output_created_listener);
919 wl_list_for_each(output, &compositor->output_list, link)
920 fs_output_create(shell, output);
922 shell->seat_created_listener.notify = seat_created;
923 wl_signal_add(&compositor->seat_created_signal,
924 &shell->seat_created_listener);
925 wl_list_for_each(seat, &compositor->seat_list, link)
926 seat_created(NULL, seat);
928 wl_global_create(compositor->wl_display,
929 &zwp_fullscreen_shell_v1_interface, 1, shell,
930 bind_fullscreen_shell);