diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2019-10-19 00:06:04 +0300 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2019-10-19 00:06:04 +0300 |
commit | b6e77dda6eae7d843b83998f5f19bc84ec8adb15 (patch) | |
tree | 0566e5d32da6dfaf47e8f5e35be741b64797b769 | |
parent | c6dcae4060976257a5fa1bfd4ee874cd9c5b7e67 (diff) | |
download | metacity-b6e77dda6eae7d843b83998f5f19bc84ec8adb15.tar.gz |
compositor-xrender: create extents only if window needs shadow
-rw-r--r-- | src/compositor/meta-compositor-xrender.c | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/src/compositor/meta-compositor-xrender.c b/src/compositor/meta-compositor-xrender.c index d461877a..2ebe3242 100644 --- a/src/compositor/meta-compositor-xrender.c +++ b/src/compositor/meta-compositor-xrender.c @@ -920,68 +920,66 @@ window_has_shadow (MetaCompositorXRender *xrender, return FALSE; } - static XserverRegion win_extents (MetaCompositorXRender *xrender, MetaCompWindow *cw) { XRectangle r; + MetaFrame *frame; + MetaFrameBorders borders; + XRectangle sr; + + if (!cw->needs_shadow) + return None; r.x = cw->rect.x; r.y = cw->rect.y; r.width = cw->rect.width; r.height = cw->rect.height; - if (cw->needs_shadow) - { - MetaFrame *frame; - MetaFrameBorders borders; - XRectangle sr; + frame = meta_window_get_frame (cw->window); + meta_frame_calc_borders (frame, &borders); - frame = meta_window_get_frame (cw->window); - meta_frame_calc_borders (frame, &borders); + cw->shadow_dx = (int) shadow_offsets_x [cw->shadow_type] + borders.invisible.left; + cw->shadow_dy = (int) shadow_offsets_y [cw->shadow_type] + borders.invisible.top; - cw->shadow_dx = (int) shadow_offsets_x [cw->shadow_type] + borders.invisible.left; - cw->shadow_dy = (int) shadow_offsets_y [cw->shadow_type] + borders.invisible.top; - - if (!cw->shadow) - { - double opacity = SHADOW_OPACITY; - int invisible_width = borders.invisible.left + borders.invisible.right; - int invisible_height = borders.invisible.top + borders.invisible.bottom; + if (!cw->shadow) + { + double opacity = SHADOW_OPACITY; + int invisible_width = borders.invisible.left + borders.invisible.right; + int invisible_height = borders.invisible.top + borders.invisible.bottom; - if (cw->window->opacity != (guint) OPAQUE) - opacity = opacity * ((double) cw->window->opacity) / ((double) OPAQUE); + if (cw->window->opacity != (guint) OPAQUE) + opacity = opacity * ((double) cw->window->opacity) / ((double) OPAQUE); - cw->shadow = shadow_picture (xrender, cw, opacity, borders, - cw->rect.width - invisible_width, - cw->rect.height - invisible_height, - &cw->shadow_width, &cw->shadow_height); - } + cw->shadow = shadow_picture (xrender, cw, opacity, borders, + cw->rect.width - invisible_width, + cw->rect.height - invisible_height, + &cw->shadow_width, &cw->shadow_height); + } - sr.x = cw->rect.x + cw->shadow_dx; - sr.y = cw->rect.y + cw->shadow_dy; - sr.width = cw->shadow_width; - sr.height = cw->shadow_height; + sr.x = cw->rect.x + cw->shadow_dx; + sr.y = cw->rect.y + cw->shadow_dy; + sr.width = cw->shadow_width; + sr.height = cw->shadow_height; - if (sr.x < r.x) - { - r.width = (r.x + r.width) - sr.x; - r.x = sr.x; - } + if (sr.x < r.x) + { + r.width = (r.x + r.width) - sr.x; + r.x = sr.x; + } - if (sr.y < r.y) - { - r.height = (r.y + r.height) - sr.y; - r.y = sr.y; - } + if (sr.y < r.y) + { + r.height = (r.y + r.height) - sr.y; + r.y = sr.y; + } - if (sr.x + sr.width > r.x + r.width) - r.width = sr.x + sr.width - r.x; + if (sr.x + sr.width > r.x + r.width) + r.width = sr.x + sr.width - r.x; - if (sr.y + sr.height > r.y + r.height) - r.height = sr.y + sr.height - r.y; - } + if (sr.y + sr.height > r.y + r.height) + r.height = sr.y + sr.height - r.y; return XFixesCreateRegion (xrender->xdisplay, &r, 1); } @@ -1824,9 +1822,12 @@ meta_compositor_xrender_pre_paint (MetaCompositor *compositor) { cw->extents = win_extents (xrender, cw); - meta_compositor_add_damage (compositor, - "meta_compositor_xrender_pre_paint", - cw->extents); + if (cw->extents != None) + { + meta_compositor_add_damage (compositor, + "meta_compositor_xrender_pre_paint", + cw->extents); + } } } } |