[mutter] frame: Add "get_corner_radiuses" chain



commit d33d11374690313c178f6e457ae7982ef808e2c3
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Jul 11 12:58:31 2011 -0400

    frame: Add "get_corner_radiuses" chain
    
    https://bugzilla.gnome.org/show_bug.cgi?id=628195

 src/core/frame.c |   13 +++++++++++++
 src/core/frame.h |    6 ++++++
 src/ui/frames.c  |   34 ++++++++++++++++++++++++++++++++++
 src/ui/frames.h  |    8 ++++++++
 src/ui/ui.c      |   14 +++++++++++++-
 src/ui/ui.h      |    7 +++++++
 6 files changed, 81 insertions(+), 1 deletions(-)
---
diff --git a/src/core/frame.c b/src/core/frame.c
index a203253..8d0c06b 100644
--- a/src/core/frame.c
+++ b/src/core/frame.c
@@ -319,6 +319,19 @@ meta_frame_calc_borders (MetaFrame        *frame,
                              borders);
 }
 
+void
+meta_frame_get_corner_radiuses (MetaFrame *frame,
+                                float     *top_left,
+                                float     *top_right,
+                                float     *bottom_left,
+                                float     *bottom_right)
+{
+  meta_ui_get_corner_radiuses (frame->window->screen->ui,
+                               frame->xwindow,
+                               top_left, top_right,
+                               bottom_left, bottom_right);
+}
+
 gboolean
 meta_frame_sync_to_window (MetaFrame *frame,
                            int        resize_gravity,
diff --git a/src/core/frame.h b/src/core/frame.h
index 64d2f20..d612f77 100644
--- a/src/core/frame.h
+++ b/src/core/frame.h
@@ -63,6 +63,12 @@ Window         meta_frame_get_xwindow (MetaFrame *frame);
 void meta_frame_calc_borders      (MetaFrame        *frame,
                                    MetaFrameBorders *borders);
 
+void meta_frame_get_corner_radiuses (MetaFrame *frame,
+                                     float     *top_left,
+                                     float     *top_right,
+                                     float     *bottom_left,
+                                     float     *bottom_right);
+
 gboolean meta_frame_sync_to_window (MetaFrame         *frame,
                                     int                gravity,
                                     gboolean           need_move,
diff --git a/src/ui/frames.c b/src/ui/frames.c
index fe67e2a..bf955d1 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -825,6 +825,40 @@ meta_frames_get_borders (MetaFrames *frames,
 }
 
 void
+meta_frames_get_corner_radiuses (MetaFrames *frames,
+                                 Window      xwindow,
+                                 float      *top_left,
+                                 float      *top_right,
+                                 float      *bottom_left,
+                                 float      *bottom_right)
+{
+  MetaUIFrame *frame;
+  MetaFrameGeometry fgeom;
+
+  frame = meta_frames_lookup_window (frames, xwindow);
+
+  meta_frames_calc_geometry (frames, frame, &fgeom);
+
+  /* For compatibility with the code in get_visible_rect(), there's
+   * a mysterious sqrt() added to the corner radiuses:
+   *
+   *   const float radius = sqrt(corner) + corner;
+   *
+   * It's unclear why the radius is calculated like this, but we
+   * need to be consistent with it.
+   */
+
+  if (top_left)
+    *top_left = fgeom.top_left_corner_rounded_radius + sqrt(fgeom.top_left_corner_rounded_radius);
+  if (top_right)
+    *top_right = fgeom.top_right_corner_rounded_radius + sqrt(fgeom.top_right_corner_rounded_radius);
+  if (bottom_left)
+    *bottom_left = fgeom.bottom_left_corner_rounded_radius + sqrt(fgeom.bottom_left_corner_rounded_radius);
+  if (bottom_right)
+    *bottom_right = fgeom.bottom_right_corner_rounded_radius + sqrt(fgeom.bottom_right_corner_rounded_radius);
+}
+
+void
 meta_frames_reset_bg (MetaFrames *frames,
                       Window  xwindow)
 {
diff --git a/src/ui/frames.h b/src/ui/frames.h
index a309170..ef9733a 100644
--- a/src/ui/frames.h
+++ b/src/ui/frames.h
@@ -148,6 +148,14 @@ cairo_region_t *meta_frames_get_frame_bounds (MetaFrames *frames,
                                               Window      xwindow,
                                               int         window_width,
                                               int         window_height);
+
+void meta_frames_get_corner_radiuses (MetaFrames *frames,
+                                      Window      xwindow,
+                                      float      *top_left,
+                                      float      *top_right,
+                                      float      *bottom_left,
+                                      float      *bottom_right);
+
 void meta_frames_move_resize_frame (MetaFrames *frames,
 				    Window      xwindow,
 				    int         x,
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 749d3e6..342af0d 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -314,6 +314,19 @@ meta_ui_get_frame_borders (MetaUI *ui,
                            borders);
 }
 
+void
+meta_ui_get_corner_radiuses (MetaUI *ui,
+                             Window  xwindow,
+                             float  *top_left,
+                             float  *top_right,
+                             float  *bottom_left,
+                             float  *bottom_right)
+{
+  meta_frames_get_corner_radiuses (ui->frames, xwindow,
+                                   top_left, top_right,
+                                   bottom_left, bottom_right);
+}
+
 Window
 meta_ui_create_frame_window (MetaUI *ui,
                              Display *xdisplay,
@@ -480,7 +493,6 @@ meta_ui_queue_frame_draw (MetaUI *ui,
   meta_frames_queue_draw (ui->frames, xwindow);
 }
 
-
 void
 meta_ui_set_frame_title (MetaUI     *ui,
                          Window      xwindow,
diff --git a/src/ui/ui.h b/src/ui/ui.h
index b264ed3..7101853 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -100,6 +100,13 @@ cairo_region_t *meta_ui_get_frame_bounds (MetaUI  *ui,
                                           int      window_width,
                                           int      window_height);
 
+void meta_ui_get_corner_radiuses (MetaUI *ui,
+                                  Window  xwindow,
+                                  float  *top_left,
+                                  float  *top_right,
+                                  float  *bottom_left,
+                                  float  *bottom_right);
+
 void meta_ui_queue_frame_draw (MetaUI *ui,
                                Window xwindow);
 



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