window/x11: Add function to convert the buffer to frame rect

Add a convenient function to get the frame rectangle from a given
buffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1009
This commit is contained in:
Olivier Fourdan 2020-01-17 17:56:12 +01:00 committed by Robert Mader
parent c0321c7b21
commit 1000ebe203
2 changed files with 23 additions and 0 deletions

View File

@ -4066,3 +4066,22 @@ meta_window_x11_always_update_shape (MetaWindow *window)
return META_WINDOW_X11_GET_CLASS (window_x11)->always_update_shape (window);
}
void
meta_window_x11_buffer_rect_to_frame_rect (MetaWindow *window,
MetaRectangle *buffer_rect,
MetaRectangle *frame_rect)
{
MetaFrameBorders borders;
g_return_if_fail (window->frame);
meta_frame_calc_borders (window->frame, &borders);
*frame_rect = *buffer_rect;
frame_rect->x += borders.invisible.left;
frame_rect->y += borders.invisible.top;
frame_rect->width -= borders.invisible.left + borders.invisible.right;
frame_rect->height -= borders.invisible.top + borders.invisible.bottom;
}

View File

@ -89,4 +89,8 @@ void meta_window_x11_set_thaw_after_paint (MetaWindow *window,
gboolean meta_window_x11_should_thaw_after_paint (MetaWindow *window);
gboolean meta_window_x11_always_update_shape (MetaWindow *window);
void meta_window_x11_buffer_rect_to_frame_rect (MetaWindow *window,
MetaRectangle *buffer_rect,
MetaRectangle *frame_rect);
#endif