diff options
author | Victor Kareh <[email protected]> | 2019-05-22 11:17:09 -0400 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-06-16 18:12:44 +0200 |
commit | 193df67ba85ca5d360bed388be0a340bd3814c47 (patch) | |
tree | 775612e0944fa44f9dabae37a88b000acf70528b /src/ui | |
parent | 1949834b11b508af71332ca92ddcce7a9733d1fd (diff) | |
download | marco-193df67ba85ca5d360bed388be0a340bd3814c47.tar.bz2 marco-193df67ba85ca5d360bed388be0a340bd3814c47.tar.xz |
MetaFrames: factor out MetaUIFrame accessors for borders, corner radiuses
This makes it a bit simpler for other functions on a MetaUIFrame to
get this information.
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=697758
Reviewed-by: Jasper St. Pierre <[email protected]>
Signed-off-by: Simon McVittie <[email protected]>
upstream commit:
https://gitlab.gnome.org/GNOME/metacity/commit/79384de0
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/frames.c | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/src/ui/frames.c b/src/ui/frames.c index 37bf6cc0..e1a30be7 100644 --- a/src/ui/frames.c +++ b/src/ui/frames.c @@ -763,22 +763,15 @@ meta_frames_lookup_window (MetaFrames *frames, return frame; } -void -meta_frames_get_borders (MetaFrames *frames, - Window xwindow, - MetaFrameBorders *borders) +static void +meta_ui_frame_get_borders (MetaFrames *frames, + MetaUIFrame *frame, + MetaFrameBorders *borders) { MetaFrameFlags flags; - MetaUIFrame *frame; MetaFrameType type; gint scale; - frame = meta_frames_lookup_window (frames, xwindow); - scale = gdk_window_get_scale_factor (frame->window); - - if (frame == NULL) - meta_bug ("No such frame 0x%lx\n", xwindow); - meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow, META_CORE_GET_FRAME_FLAGS, &flags, META_CORE_GET_FRAME_TYPE, &type, @@ -786,6 +779,8 @@ meta_frames_get_borders (MetaFrames *frames, g_return_if_fail (type < META_FRAME_TYPE_LAST); + scale = gdk_window_get_scale_factor (frame->window); + meta_frames_ensure_layout (frames, frame); /* We can't get the full geometry, because that depends on @@ -807,18 +802,30 @@ meta_frames_get_borders (MetaFrames *frames, } void -meta_frames_get_corner_radiuses (MetaFrames *frames, +meta_frames_get_borders (MetaFrames *frames, Window xwindow, + MetaFrameBorders *borders) +{ + MetaUIFrame *frame; + + frame = meta_frames_lookup_window (frames, xwindow); + + if (frame == NULL) + g_error ("No such frame 0x%lx\n", xwindow); + + meta_ui_frame_get_borders (frames, frame, borders); +} + +static void +meta_ui_frame_get_corner_radiuses (MetaFrames *frames, + MetaUIFrame *frame, 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 @@ -840,6 +847,22 @@ meta_frames_get_corner_radiuses (MetaFrames *frames, *bottom_right = fgeom.bottom_right_corner_rounded_radius + sqrt(fgeom.bottom_right_corner_rounded_radius); } +void +meta_frames_get_corner_radiuses (MetaFrames *frames, + Window xwindow, + float *top_left, + float *top_right, + float *bottom_left, + float *bottom_right) +{ + MetaUIFrame *frame; + + frame = meta_frames_lookup_window (frames, xwindow); + + meta_ui_frame_get_corner_radiuses (frames, frame, top_left, top_right, + bottom_left, bottom_right); +} + #ifdef HAVE_SHAPE static void apply_cairo_region_to_window (Display *display, |