5 #include <glib-object.h>
7 #include "clutter-actor.h"
8 #include "clutter-stage-window.h"
9 #include "clutter-private.h"
11 #define clutter_stage_window_get_type _clutter_stage_window_get_type
13 typedef ClutterStageWindowIface ClutterStageWindowInterface;
15 G_DEFINE_INTERFACE (ClutterStageWindow, clutter_stage_window, G_TYPE_OBJECT);
18 clutter_stage_window_default_init (ClutterStageWindowInterface *iface)
22 pspec = g_param_spec_object ("backend",
24 "Back pointer to the Backend instance",
27 G_PARAM_CONSTRUCT_ONLY |
28 G_PARAM_STATIC_STRINGS);
29 g_object_interface_install_property (iface, pspec);
31 pspec = g_param_spec_object ("wrapper",
33 "Back pointer to the Stage actor",
36 G_PARAM_CONSTRUCT_ONLY |
37 G_PARAM_STATIC_STRINGS);
38 g_object_interface_install_property (iface, pspec);
42 _clutter_stage_window_get_wrapper (ClutterStageWindow *window)
44 return CLUTTER_STAGE_WINDOW_GET_IFACE (window)->get_wrapper (window);
48 _clutter_stage_window_set_title (ClutterStageWindow *window,
51 ClutterStageWindowIface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
54 iface->set_title (window, title);
58 _clutter_stage_window_set_fullscreen (ClutterStageWindow *window,
59 gboolean is_fullscreen)
61 ClutterStageWindowIface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
63 if (iface->set_fullscreen)
64 iface->set_fullscreen (window, is_fullscreen);
68 _clutter_stage_window_set_cursor_visible (ClutterStageWindow *window,
71 ClutterStageWindowIface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
73 if (iface->set_cursor_visible)
74 iface->set_cursor_visible (window, is_visible);
78 _clutter_stage_window_set_user_resizable (ClutterStageWindow *window,
79 gboolean is_resizable)
81 CLUTTER_STAGE_WINDOW_GET_IFACE (window)->set_user_resizable (window,
86 _clutter_stage_window_realize (ClutterStageWindow *window)
88 return CLUTTER_STAGE_WINDOW_GET_IFACE (window)->realize (window);
92 _clutter_stage_window_unrealize (ClutterStageWindow *window)
94 CLUTTER_STAGE_WINDOW_GET_IFACE (window)->unrealize (window);
98 _clutter_stage_window_show (ClutterStageWindow *window,
101 CLUTTER_STAGE_WINDOW_GET_IFACE (window)->show (window, do_raise);
105 _clutter_stage_window_hide (ClutterStageWindow *window)
107 CLUTTER_STAGE_WINDOW_GET_IFACE (window)->hide (window);
111 _clutter_stage_window_resize (ClutterStageWindow *window,
115 CLUTTER_STAGE_WINDOW_GET_IFACE (window)->resize (window, width, height);
119 _clutter_stage_window_get_geometry (ClutterStageWindow *window,
120 cairo_rectangle_int_t *geometry)
122 CLUTTER_STAGE_WINDOW_GET_IFACE (window)->get_geometry (window, geometry);
126 _clutter_stage_window_get_pending_swaps (ClutterStageWindow *window)
128 ClutterStageWindowIface *iface;
130 g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), 0);
132 iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
133 if (iface->get_pending_swaps == NULL)
135 g_assert (!clutter_feature_available (CLUTTER_FEATURE_SWAP_EVENTS));
139 return iface->get_pending_swaps (window);
143 _clutter_stage_window_add_redraw_clip (ClutterStageWindow *window,
144 cairo_rectangle_int_t *stage_clip)
146 ClutterStageWindowIface *iface;
148 g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
150 iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
151 if (iface->add_redraw_clip != NULL)
152 iface->add_redraw_clip (window, stage_clip);
155 /* Determines if the backend will clip the rendering of the next
158 * Note: at the start of each new frame there is an implied clip that
159 * clips everything (i.e. nothing would be drawn) so this function
160 * will return True at the start of a new frame if the backend
161 * supports clipped redraws.
164 _clutter_stage_window_has_redraw_clips (ClutterStageWindow *window)
166 ClutterStageWindowIface *iface;
168 g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
170 iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
171 if (iface->has_redraw_clips != NULL)
172 return iface->has_redraw_clips (window);
177 /* Determines if the backend will discard any additional redraw clips
178 * and instead promote them to a full stage redraw.
180 * The ideas is that backend may have some heuristics that cause it to
181 * give up tracking redraw clips so this can be used to avoid the cost
182 * of calculating a redraw clip when we know it's going to be ignored
186 _clutter_stage_window_ignoring_redraw_clips (ClutterStageWindow *window)
188 ClutterStageWindowIface *iface;
190 g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
192 iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
193 if (iface->ignoring_redraw_clips != NULL)
194 return iface->ignoring_redraw_clips (window);
200 _clutter_stage_window_get_redraw_clip_bounds (ClutterStageWindow *window,
201 cairo_rectangle_int_t *stage_clip)
203 ClutterStageWindowIface *iface;
205 g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
207 iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
208 if (iface->get_redraw_clip_bounds != NULL)
209 return iface->get_redraw_clip_bounds (window, stage_clip);
215 _clutter_stage_window_set_accept_focus (ClutterStageWindow *window,
216 gboolean accept_focus)
218 ClutterStageWindowIface *iface;
220 g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
222 iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
223 if (iface->set_accept_focus)
224 iface->set_accept_focus (window, accept_focus);
228 _clutter_stage_window_redraw (ClutterStageWindow *window)
230 ClutterStageWindowIface *iface;
232 g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
234 iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
236 iface->redraw (window);
239 /* NB: The presumption shouldn't be that a stage can't be comprised of
240 * multiple internal framebuffers, so instead of simply naming this
241 * function _clutter_stage_window_get_framebuffer(), the "active"
242 * infix is intended to clarify that it gets the framebuffer that is
243 * currently in use/being painted.
246 _clutter_stage_window_get_active_framebuffer (ClutterStageWindow *window)
248 ClutterStageWindowIface *iface;
250 g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), NULL);
252 iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
253 if (iface->get_active_framebuffer)
254 return iface->get_active_framebuffer (window);
260 _clutter_stage_window_can_clip_redraws (ClutterStageWindow *window)
262 ClutterStageWindowIface *iface;
264 g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
266 iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
267 if (iface->can_clip_redraws != NULL)
268 return iface->can_clip_redraws (window);