static void clutter_stage_wayland_add_redraw_clip (ClutterStageWindow *stage_window, ClutterGeometry *stage_clip) { ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window); cairo_rectangle_int_t rect; if (stage_clip == NULL) { rect.x = stage_wayland->allocation.x; rect.y = stage_wayland->allocation.y; rect.width = stage_wayland->allocation.width; rect.height = stage_wayland->allocation.height; } else { rect.x = stage_clip->x; rect.y = stage_clip->y; rect.width = stage_clip->width; rect.height = stage_clip->height; } if (stage_wayland->repaint_region == NULL) stage_wayland->repaint_region = cairo_region_create_rectangle (&rect); else cairo_region_union_rectangle (stage_wayland->repaint_region, &rect); }
static int clutter_stage_wayland_get_pending_swaps (ClutterStageWindow *stage_window) { ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window); return stage_wayland->pending_swaps; }
static void clutter_stage_wayland_hide (ClutterStageWindow *stage_window) { ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window); clutter_actor_unmap (CLUTTER_ACTOR (stage_wayland->wrapper)); }
static gboolean clutter_stage_wayland_realize (ClutterStageWindow *stage_window) { ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window); ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window); struct wl_surface *wl_surface; struct wl_shell_surface *wl_shell_surface; clutter_stage_window_parent_iface->realize (stage_window); wl_surface = cogl_wayland_onscreen_get_surface (stage_cogl->onscreen); wl_surface_set_user_data (wl_surface, stage_wayland); wl_shell_surface = cogl_wayland_onscreen_get_shell_surface (stage_cogl->onscreen); wl_shell_surface_add_listener (wl_shell_surface, &shell_surface_listener, stage_wayland); stage_wayland->wayland_surface = wl_surface; stage_wayland->wayland_shell_surface = wl_shell_surface; if (stage_wayland->fullscreen) clutter_stage_wayland_set_fullscreen (stage_window, TRUE); return TRUE; }
static void clutter_stage_wayland_show (ClutterStageWindow *stage_window, gboolean do_raise) { ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window); clutter_actor_map (CLUTTER_ACTOR (stage_wayland->wrapper)); }
static void clutter_stage_wayland_get_geometry (ClutterStageWindow *stage_window, ClutterGeometry *geometry) { ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window); if (geometry) { *geometry = stage_wayland->allocation; } }
/** * clutter_wayland_stage_get_wl_shell_surface: (skip) * * @stage: a #ClutterStage * * Access the underlying data structure representing the shell surface that is * backing the #ClutterStage * * Note: this function can only be called when running on the Wayland * platform. Calling this function at any other time will return %NULL. * * Returns: (transfer non): the Wayland shell surface associated with * @stage * * Since: 1.10 */ struct wl_shell_surface * clutter_wayland_stage_get_wl_shell_surface (ClutterStage *stage) { ClutterStageWindow *stage_window = _clutter_stage_get_window (stage); ClutterStageWayland *stage_wayland; if (!CLUTTER_IS_STAGE_WAYLAND (stage_window)) return NULL; stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window); return stage_wayland->wayland_shell_surface; }
static void clutter_backend_wayland_redraw (ClutterBackend *backend, ClutterStage *stage) { ClutterStageWindow *impl; impl = _clutter_stage_get_window (stage); if (!impl) return; g_assert (CLUTTER_IS_STAGE_WAYLAND (impl)); _clutter_stage_wayland_redraw (CLUTTER_STAGE_WAYLAND (impl), stage); }
static void clutter_stage_wayland_set_fullscreen (ClutterStageWindow *stage_window, gboolean fullscreen) { ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window); ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window); ClutterBackend *backend = CLUTTER_BACKEND (stage_cogl->backend); ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend); ClutterActor *stage = _clutter_stage_window_get_wrapper (stage_window); stage_wayland->fullscreen = fullscreen; if (!stage_wayland->wayland_shell_surface) /* Not realized yet */ return; if (fullscreen) { _clutter_stage_update_state (stage_cogl->wrapper, 0, CLUTTER_STAGE_STATE_FULLSCREEN); /* FIXME: In future versions of the Wayland protocol we'll get a * configure with the dimensions we can use - but for now we have to * use the dimensions from the output's mode */ clutter_actor_set_size (stage, backend_wayland->output_width, backend_wayland->output_height); /* FIXME: And we must force a redraw so that new sized buffer gets * attached */ _clutter_stage_window_redraw (stage_window); wl_shell_surface_set_fullscreen (stage_wayland->wayland_shell_surface, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL); } else { _clutter_stage_update_state (stage_cogl->wrapper, CLUTTER_STAGE_STATE_FULLSCREEN, 0); wl_shell_surface_set_toplevel (stage_wayland->wayland_shell_surface); } }
static ClutterStageWindow * clutter_backend_wayland_create_stage (ClutterBackend *backend, ClutterStage *wrapper, GError **error) { ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend); ClutterStageWindow *stage; ClutterStageWayland *stage_wayland; stage = g_object_new (CLUTTER_TYPE_STAGE_WAYLAND, NULL); stage_wayland = CLUTTER_STAGE_WAYLAND (stage); stage_wayland->backend = backend_wayland; stage_wayland->wrapper = wrapper; return stage; }
static void clutter_stage_wayland_unrealize (ClutterStageWindow *stage_window) { ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window); if (stage_wayland->front_buffer) { wayland_free_buffer (stage_wayland->front_buffer); stage_wayland->front_buffer = NULL; } if (stage_wayland->back_buffer) { wayland_free_buffer (stage_wayland->back_buffer); stage_wayland->back_buffer = NULL; } wayland_free_buffer (stage_wayland->pick_buffer); }
static void clutter_stage_wayland_resize (ClutterStageWindow *stage_window, gint width, gint height) { ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window); cairo_rectangle_int_t rect; fprintf (stderr, "resize %dx%d\n", width, height); stage_wayland->pending_allocation.width = width; stage_wayland->pending_allocation.height = height; /* FIXME: Shouldn't the stage repaint everything when it gets resized? */ rect.x = stage_wayland->pending_allocation.x; rect.y = stage_wayland->pending_allocation.y; rect.width = stage_wayland->pending_allocation.width; rect.height = stage_wayland->pending_allocation.height; cairo_region_union_rectangle (stage_wayland->repaint_region, &rect); }
static gboolean clutter_stage_wayland_realize (ClutterStageWindow *stage_window) { ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window); ClutterBackend *backend = clutter_get_default_backend (); ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend); gfloat width, height; clutter_actor_get_size (CLUTTER_ACTOR (stage_wayland->wrapper), &width, &height); stage_wayland->pending_allocation.width = (gint)width; stage_wayland->pending_allocation.height = (gint)height; stage_wayland->allocation = stage_wayland->pending_allocation; stage_wayland->wayland_surface = wl_compositor_create_surface (backend_wayland->wayland_compositor); wl_surface_set_user_data (stage_wayland->wayland_surface, stage_wayland); stage_wayland->pick_buffer = wayland_create_buffer (&stage_wayland->allocation); return TRUE; }
static ClutterActor * clutter_stage_wayland_get_wrapper (ClutterStageWindow *stage_window) { return CLUTTER_ACTOR (CLUTTER_STAGE_WAYLAND (stage_window)->wrapper); }