summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2019-05-22 07:21:05 -0400
committerraveit65 <[email protected]>2019-06-16 18:12:44 +0200
commit940afededd6caab7c977a43f202457c10129aec2 (patch)
treecedc28bceee7062398e04cdf38c50f942862caaf /src
parent1babf371e4b390f9d9668667b61ea35678a5068c (diff)
downloadmarco-940afededd6caab7c977a43f202457c10129aec2.tar.bz2
marco-940afededd6caab7c977a43f202457c10129aec2.tar.xz
compositor: don't draw shadow under windows
upstream commit: https://gitlab.gnome.org/GNOME/metacity/commit/5404d8f2
Diffstat (limited to 'src')
-rw-r--r--src/compositor/compositor-xrender.c71
-rw-r--r--src/core/frame-private.h3
-rw-r--r--src/include/frame.h3
3 files changed, 66 insertions, 11 deletions
diff --git a/src/compositor/compositor-xrender.c b/src/compositor/compositor-xrender.c
index de112db9..103d246b 100644
--- a/src/compositor/compositor-xrender.c
+++ b/src/compositor/compositor-xrender.c
@@ -589,12 +589,59 @@ 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,
+ MetaFrameBorders borders,
int width,
int height,
int *wp,
@@ -621,8 +668,7 @@ shadow_picture (MetaDisplay *display,
}
shadow_picture = XRenderCreatePicture (xdisplay, shadow_pixmap,
- XRenderFindStandardFormat (xdisplay,
-PictStandardA8),
+ XRenderFindStandardFormat (xdisplay, PictStandardA8),
0, 0);
if (!shadow_picture)
{
@@ -630,6 +676,10 @@ PictStandardA8),
XFreePixmap (xdisplay, shadow_pixmap);
return None;
}
+ shadow_clip (xdisplay,
+ shadow_picture, shadow_image, shadow_type,
+ borders,
+ width, height);
gc = XCreateGC (xdisplay, shadow_pixmap, 0, 0);
if (!gc)
@@ -984,12 +1034,6 @@ 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)
{
@@ -1005,8 +1049,18 @@ 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];
@@ -1018,6 +1072,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 a5c01995..1b995f58 100644
--- a/src/core/frame-private.h
+++ b/src/core/frame-private.h
@@ -59,9 +59,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 367c50fb..97314d4b 100644
--- a/src/include/frame.h
+++ b/src/include/frame.h
@@ -24,8 +24,11 @@
#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