[metacity] compositor: don't draw shadow under windows
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] compositor: don't draw shadow under windows
- Date: Mon, 19 Jan 2015 02:51:27 +0000 (UTC)
commit 5404d8f2c9d10f2dfcbb928978836256290c547a
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Jan 19 04:49:56 2015 +0200
compositor: don't draw shadow under windows
src/compositor/compositor-xrender.c | 93 ++++++++++++++++++++++++++++------
src/core/frame-private.h | 3 -
src/include/frame.h | 4 ++
3 files changed, 80 insertions(+), 20 deletions(-)
---
diff --git a/src/compositor/compositor-xrender.c b/src/compositor/compositor-xrender.c
index 99e10b2..dd99329 100644
--- a/src/compositor/compositor-xrender.c
+++ b/src/compositor/compositor-xrender.c
@@ -592,16 +592,64 @@ make_shadow (MetaDisplay *display,
return ximage;
}
+double shadow_offsets_x[LAST_SHADOW_TYPE] = {SHADOW_SMALL_OFFSET_X,
+ SHADOW_MEDIUM_OFFSET_X,
+ SHADOW_LARGE_OFFSET_X};
+double shadow_offsets_y[LAST_SHADOW_TYPE] = {SHADOW_SMALL_OFFSET_Y,
+ SHADOW_MEDIUM_OFFSET_Y,
+ SHADOW_LARGE_OFFSET_Y};
+
+static void
+shadow_clip (Display *xdisplay,
+ Picture shadow_picture,
+ XImage *shadow_image,
+ MetaShadowType shadow_type,
+ MetaFrameBorders borders,
+ int width,
+ int height)
+{
+ int shadow_dx = -1 * shadow_offsets_x [shadow_type];
+ int shadow_dy = -1 * shadow_offsets_y [shadow_type];
+ XRectangle clip[4];
+
+ /* Top */
+ clip[0].x = 0;
+ clip[0].y = 0;
+ clip[0].width = shadow_image->width;
+ clip[0].height = shadow_dy + borders.visible.top;
+
+ /* Bottom */
+ clip[1].x = 0;
+ clip[1].y = shadow_dy + (height - borders.visible.bottom);
+ clip[1].width = shadow_image->width;
+ clip[1].height = shadow_image->height - (shadow_dy + (height - borders.visible.bottom));
+
+ /* Left */
+ clip[2].x = 0;
+ clip[2].y = shadow_dy + borders.visible.top;
+ clip[2].width = shadow_dx + borders.visible.left;
+ clip[2].height = height - borders.visible.top - borders.visible.bottom;
+
+ /* Right */
+ clip[3].x = width + shadow_dx;
+ clip[3].y = shadow_dy + borders.visible.top;
+ clip[3].width = shadow_image->width - (width + shadow_dx);
+ clip[3].height = height - borders.visible.top - borders.visible.bottom;
+
+ XRenderSetPictureClipRectangles (xdisplay, shadow_picture, 0, 0, clip, 4);
+}
+
static Picture
-shadow_picture (MetaDisplay *display,
- MetaScreen *screen,
- MetaShadowType shadow_type,
- double opacity,
- Picture alpha_pict,
- int width,
- int height,
- int *wp,
- int *hp)
+shadow_picture (MetaDisplay *display,
+ MetaScreen *screen,
+ MetaShadowType shadow_type,
+ double opacity,
+ Picture alpha_pict,
+ MetaFrameBorders borders,
+ int width,
+ int height,
+ int *wp,
+ int *hp)
{
Display *xdisplay = meta_display_get_xdisplay (display);
XImage *shadow_image;
@@ -624,8 +672,7 @@ shadow_picture (MetaDisplay *display,
}
shadow_picture = XRenderCreatePicture (xdisplay, shadow_pixmap,
- XRenderFindStandardFormat (xdisplay,
-PictStandardA8),
+ XRenderFindStandardFormat (xdisplay, PictStandardA8),
0, 0);
if (!shadow_picture)
{
@@ -634,6 +681,11 @@ PictStandardA8),
return None;
}
+ shadow_clip (xdisplay,
+ shadow_picture, shadow_image, shadow_type,
+ borders,
+ width, height);
+
gc = XCreateGC (xdisplay, shadow_pixmap, 0, 0);
if (!gc)
{
@@ -950,12 +1002,7 @@ window_has_shadow (MetaCompWindow *cw)
return FALSE;
}
-double shadow_offsets_x[LAST_SHADOW_TYPE] = {SHADOW_SMALL_OFFSET_X,
- SHADOW_MEDIUM_OFFSET_X,
- SHADOW_LARGE_OFFSET_X};
-double shadow_offsets_y[LAST_SHADOW_TYPE] = {SHADOW_SMALL_OFFSET_Y,
- SHADOW_MEDIUM_OFFSET_Y,
- SHADOW_LARGE_OFFSET_Y};
+
static XserverRegion
win_extents (MetaCompWindow *cw)
{
@@ -971,8 +1018,19 @@ win_extents (MetaCompWindow *cw)
if (cw->needs_shadow)
{
+ MetaFrameBorders borders;
XRectangle sr;
+ meta_frame_borders_clear (&borders);
+
+ if (cw->window)
+ {
+ MetaFrame *frame = meta_window_get_frame (cw->window);
+
+ if (frame)
+ meta_frame_calc_borders (frame, &borders);
+ }
+
cw->shadow_dx = shadow_offsets_x [cw->shadow_type];
cw->shadow_dy = shadow_offsets_y [cw->shadow_type];
@@ -984,6 +1042,7 @@ win_extents (MetaCompWindow *cw)
cw->shadow = shadow_picture (display, screen, cw->shadow_type,
opacity, cw->alpha_pict,
+ borders,
cw->attrs.width + cw->attrs.border_width * 2,
cw->attrs.height + cw->attrs.border_width * 2,
&cw->shadow_width, &cw->shadow_height);
diff --git a/src/core/frame-private.h b/src/core/frame-private.h
index fe9cdb7..eafc324 100644
--- a/src/core/frame-private.h
+++ b/src/core/frame-private.h
@@ -57,9 +57,6 @@ void meta_frame_queue_draw (MetaFrame *frame);
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_sync_to_window (MetaFrame *frame,
int gravity,
gboolean need_move,
diff --git a/src/include/frame.h b/src/include/frame.h
index 09b7457..5a0ae25 100644
--- a/src/include/frame.h
+++ b/src/include/frame.h
@@ -22,8 +22,12 @@
#include <X11/Xlib.h>
+#include "common.h"
#include "types.h"
Window meta_frame_get_xwindow (MetaFrame *frame);
+void meta_frame_calc_borders (MetaFrame *frame,
+ MetaFrameBorders *borders);
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]