[metacity/wip/gtk-theme: 40/51] frame: Add "get_corner_radiuses" chain



commit f9776030733d5a5843e117dbffd14888d9c47af9
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-private.h |    7 +++++++
 src/core/frame.c         |   13 +++++++++++++
 src/include/ui.h         |    7 +++++++
 src/ui/frames.c          |   34 ++++++++++++++++++++++++++++++++++
 src/ui/frames.h          |    8 ++++++++
 src/ui/ui.c              |   13 +++++++++++++
 6 files changed, 82 insertions(+), 0 deletions(-)
---
diff --git a/src/core/frame-private.h b/src/core/frame-private.h
index 1bd30c2..5a35334 100644
--- a/src/core/frame-private.h
+++ b/src/core/frame-private.h
@@ -60,6 +60,13 @@ MetaFrameFlags meta_frame_get_flags (MetaFrame *frame);
 /* These should ONLY be called from meta_window_move_resize_internal */
 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/core/frame.c b/src/core/frame.c
index 23d1d5d..bf370a5 100644
--- a/src/core/frame.c
+++ b/src/core/frame.c
@@ -343,6 +343,19 @@ update_shape (MetaFrame *frame)
     return FALSE;
 }
 
+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/include/ui.h b/src/include/ui.h
index d2dd07c..fb8db68 100644
--- a/src/include/ui.h
+++ b/src/include/ui.h
@@ -106,6 +106,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);
 
diff --git a/src/ui/frames.c b/src/ui/frames.c
index fb21e10..232c040 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -805,6 +805,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 9ab997f..c52fa71 100644
--- a/src/ui/frames.h
+++ b/src/ui/frames.h
@@ -152,6 +152,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 b216f44..ac5a2d7 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -311,6 +311,19 @@ meta_ui_get_frame_borders (MetaUI *ui,
   meta_frames_get_borders (ui->frames, frame_xwindow, 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,


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