[mutter] window: Add function to calculate current bounds



commit 17e239246a6e290a67c7c4098f56a1171b9b6eff
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Dec 17 21:42:35 2021 +0100

    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>

 src/core/window-private.h |  4 ++++
 src/core/window.c         | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index ad1dd5a863..8d2d4a0203 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -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
diff --git a/src/core/window.c b/src/core/window.c
index 4a0c6242e0..595177b9ae 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -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;
+    }
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]