window: Add function to calculate current bounds

This will later be used to tell Wayland clients about a size they
shouldn't exceed.

If the window doesn't have a main monitor, this function does nothing
and returns FALSE.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
This commit is contained in:
Jonas Ådahl 2021-12-17 21:42:35 +01:00 committed by Marge Bot
parent 213f0d8dd3
commit 17e239246a
2 changed files with 30 additions and 0 deletions

View File

@ -912,4 +912,8 @@ void meta_window_clear_queued (MetaWindow *window);
void meta_window_update_layout (MetaWindow *window);
gboolean meta_window_calculate_bounds (MetaWindow *window,
int *bounds_width,
int *bounds_height);
#endif

View File

@ -8555,3 +8555,29 @@ meta_window_get_alive (MetaWindow *window)
{
return window->is_alive;
}
gboolean
meta_window_calculate_bounds (MetaWindow *window,
int *bounds_width,
int *bounds_height)
{
MetaLogicalMonitor *main_monitor;
main_monitor = meta_window_get_main_logical_monitor (window);
if (main_monitor)
{
MetaRectangle work_area;
meta_window_get_work_area_for_logical_monitor (window,
main_monitor,
&work_area);
*bounds_width = work_area.width;
*bounds_height = work_area.height;
return TRUE;
}
else
{
return FALSE;
}
}