From c0321c7b214ecf262ebe160da472f0dff4eaf01a Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Thu, 16 Jan 2020 11:42:04 +0100 Subject: [PATCH] frame: Pass the frame area for get_mask() Currently, `meta_frame_get_mask()` and `meta_ui_frame_get_mask()` will return the frame mask applied to the current frame size, by querying the frame themselves. To be able to get the frame mask at an arbitrary size, change the API to take a rectangle representing the size at which the frame mask should be rendered. https://gitlab.gnome.org/GNOME/mutter/merge_requests/1009 --- src/compositor/meta-window-actor-x11.c | 5 ++++- src/core/frame.c | 7 ++++--- src/core/frame.h | 5 +++-- src/ui/frames.c | 14 ++++++-------- src/ui/frames.h | 5 +++-- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/compositor/meta-window-actor-x11.c b/src/compositor/meta-window-actor-x11.c index 81816bae0..cd2aa2edd 100644 --- a/src/compositor/meta-window-actor-x11.c +++ b/src/compositor/meta-window-actor-x11.c @@ -890,6 +890,9 @@ build_and_scan_frame_mask (MetaWindowActorX11 *actor_x11, { cairo_region_t *frame_paint_region, *scanned_region; cairo_rectangle_int_t rect = { 0, 0, tex_width, tex_height }; + cairo_rectangle_int_t frame_rect; + + meta_window_get_frame_rect (window, &frame_rect); /* Make sure we don't paint the frame over the client window. */ frame_paint_region = cairo_region_create_rectangle (&rect); @@ -899,7 +902,7 @@ build_and_scan_frame_mask (MetaWindowActorX11 *actor_x11, gdk_cairo_region (cr, frame_paint_region); cairo_clip (cr); - meta_frame_get_mask (window->frame, cr); + meta_frame_get_mask (window->frame, &frame_rect, cr); cairo_surface_flush (image); scanned_region = scan_visible_region (mask_data, stride, frame_paint_region); diff --git a/src/core/frame.c b/src/core/frame.c index 57225d554..b58ad1173 100644 --- a/src/core/frame.c +++ b/src/core/frame.c @@ -371,10 +371,11 @@ meta_frame_get_frame_bounds (MetaFrame *frame) } void -meta_frame_get_mask (MetaFrame *frame, - cairo_t *cr) +meta_frame_get_mask (MetaFrame *frame, + cairo_rectangle_int_t *frame_rect, + cairo_t *cr) { - meta_ui_frame_get_mask (frame->ui_frame, cr); + meta_ui_frame_get_mask (frame->ui_frame, frame_rect, cr); } void diff --git a/src/core/frame.h b/src/core/frame.h index c0bacbe6f..61a5ca725 100644 --- a/src/core/frame.h +++ b/src/core/frame.h @@ -72,8 +72,9 @@ void meta_frame_clear_cached_borders (MetaFrame *frame); cairo_region_t *meta_frame_get_frame_bounds (MetaFrame *frame); -void meta_frame_get_mask (MetaFrame *frame, - cairo_t *cr); +void meta_frame_get_mask (MetaFrame *frame, + cairo_rectangle_int_t *frame_rect, + cairo_t *cr); void meta_frame_set_screen_cursor (MetaFrame *frame, MetaCursor cursor); diff --git a/src/ui/frames.c b/src/ui/frames.c index 4bf8adca9..0f3bcbd2b 100644 --- a/src/ui/frames.c +++ b/src/ui/frames.c @@ -1423,22 +1423,20 @@ get_visible_frame_border_region (MetaUIFrame *frame) * frame's alpha channel, as a mask to be applied to an opaque pixmap. * * @frame: This frame - * @xwindow: The X window for the frame, which has the client window as a child + * @frame_rect: The frame rect * @cr: Used to draw the resulting mask */ void -meta_ui_frame_get_mask (MetaUIFrame *frame, - cairo_t *cr) +meta_ui_frame_get_mask (MetaUIFrame *frame, + cairo_rectangle_int_t *frame_rect, + cairo_t *cr) { MetaFrameBorders borders; MetaFrameFlags flags; - MetaRectangle frame_rect; cairo_surface_t *surface; double xscale, yscale; int scale; - meta_window_get_frame_rect (frame->meta_window, &frame_rect); - flags = meta_frame_get_flags (frame->meta_window->frame); meta_style_info_set_flags (frame->style_info, flags); @@ -1453,11 +1451,11 @@ meta_ui_frame_get_mask (MetaUIFrame *frame, gtk_render_background (frame->style_info->styles[META_STYLE_ELEMENT_FRAME], cr, borders.invisible.left / scale, borders.invisible.top / scale, - frame_rect.width / scale, frame_rect.height / scale); + frame_rect->width / scale, frame_rect->height / scale); gtk_render_background (frame->style_info->styles[META_STYLE_ELEMENT_TITLEBAR], cr, borders.invisible.left / scale, borders.invisible.top / scale, - frame_rect.width / scale, borders.total.top / scale); + frame_rect->width / scale, borders.total.top / scale); cairo_surface_set_device_scale (surface, xscale, yscale); } diff --git a/src/ui/frames.h b/src/ui/frames.h index c69f7c2f1..73dee1737 100644 --- a/src/ui/frames.h +++ b/src/ui/frames.h @@ -135,8 +135,9 @@ void meta_ui_frame_get_borders (MetaUIFrame *frame, cairo_region_t * meta_ui_frame_get_bounds (MetaUIFrame *frame); -void meta_ui_frame_get_mask (MetaUIFrame *frame, - cairo_t *cr); +void meta_ui_frame_get_mask (MetaUIFrame *frame, + cairo_rectangle_int_t *frame_rect, + cairo_t *cr); void meta_ui_frame_move_resize (MetaUIFrame *frame, int x, int y, int width, int height);