meta/boxes: typedef cairo_rectangle_int_t MetaRectangle

They are already effectively interchangeable so this should reduce
pointless casts.

Just like in GDK though, we need to keep the old definition for
instrospection to be able to include the struct's fields.
This commit is contained in:
Rui Matos 2016-06-12 18:38:35 +02:00
parent 0745734ba5
commit daf5a112fb
5 changed files with 16 additions and 22 deletions

View File

@ -1037,14 +1037,12 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
CoglOnscreen *onscreen; CoglOnscreen *onscreen;
CoglFramebuffer *framebuffer; CoglFramebuffer *framebuffer;
cairo_rectangle_int_t view_layout;
MetaRendererView *view; MetaRendererView *view;
GError *error = NULL; GError *error = NULL;
view_layout = meta_rectangle_to_cairo_rectangle (&monitor_info->rect);
onscreen = cogl_onscreen_new (cogl_context, onscreen = cogl_onscreen_new (cogl_context,
view_layout.width, monitor_info->rect.width,
view_layout.height); monitor_info->rect.height);
cogl_onscreen_set_swap_throttled (onscreen, cogl_onscreen_set_swap_throttled (onscreen,
_clutter_get_sync_to_vblank ()); _clutter_get_sync_to_vblank ());
@ -1054,7 +1052,7 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
error->message); error->message);
view = g_object_new (META_TYPE_RENDERER_VIEW, view = g_object_new (META_TYPE_RENDERER_VIEW,
"layout", &view_layout, "layout", &monitor_info->rect,
"framebuffer", framebuffer, "framebuffer", framebuffer,
"monitor-info", monitor_info, "monitor-info", monitor_info,
NULL); NULL);

View File

@ -76,7 +76,6 @@ meta_renderer_x11_create_view (MetaRenderer *renderer,
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
int width, height; int width, height;
cairo_rectangle_int_t view_layout;
CoglTexture2D *texture_2d; CoglTexture2D *texture_2d;
CoglOffscreen *offscreen; CoglOffscreen *offscreen;
@ -86,10 +85,9 @@ meta_renderer_x11_create_view (MetaRenderer *renderer,
height = monitor_info->rect.height; height = monitor_info->rect.height;
texture_2d = cogl_texture_2d_new_with_size (cogl_context, width, height); texture_2d = cogl_texture_2d_new_with_size (cogl_context, width, height);
offscreen = cogl_offscreen_new_with_texture (COGL_TEXTURE (texture_2d)); offscreen = cogl_offscreen_new_with_texture (COGL_TEXTURE (texture_2d));
view_layout = meta_rectangle_to_cairo_rectangle (&monitor_info->rect);
return g_object_new (META_TYPE_RENDERER_VIEW, return g_object_new (META_TYPE_RENDERER_VIEW,
"layout", &view_layout, "layout", &monitor_info->rect,
"framebuffer", COGL_FRAMEBUFFER (offscreen), "framebuffer", COGL_FRAMEBUFFER (offscreen),
NULL); NULL);
} }

View File

@ -215,6 +215,4 @@ GList* meta_rectangle_find_nonintersected_monitor_edges (
const GList *monitor_rects, const GList *monitor_rects,
const GSList *all_struts); const GSList *all_struts);
cairo_rectangle_int_t meta_rectangle_to_cairo_rectangle (MetaRectangle *rect);
#endif /* META_BOXES_PRIVATE_H */ #endif /* META_BOXES_PRIVATE_H */

View File

@ -2013,14 +2013,3 @@ meta_rectangle_find_nonintersected_monitor_edges (
return ret; return ret;
} }
cairo_rectangle_int_t
meta_rectangle_to_cairo_rectangle (MetaRectangle *rect)
{
return (cairo_rectangle_int_t) {
.x = rect->x,
.y = rect->y,
.width = rect->width,
.height = rect->height
};
}

View File

@ -34,7 +34,14 @@
* @width: Width of the rectangle * @width: Width of the rectangle
* @height: Height of the rectangle * @height: Height of the rectangle
*/ */
typedef struct _MetaRectangle MetaRectangle; #ifdef __GI_SCANNER__
/* The introspection scanner is currently unable to lookup how
* cairo_rectangle_int_t is actually defined. This prevents
* introspection data for the GdkRectangle type to include fields
* descriptions. To workaround this issue, we define it with the same
* content as cairo_rectangle_int_t, but only under the introspection
* define.
*/
struct _MetaRectangle struct _MetaRectangle
{ {
int x; int x;
@ -42,6 +49,10 @@ struct _MetaRectangle
int width; int width;
int height; int height;
}; };
typedef struct _MetaRectangle MetaRectangle;
#else
typedef cairo_rectangle_int_t MetaRectangle;
#endif
/** /**
* MetaStrut: * MetaStrut: