From 726bb9ea134fbf90df24e8a2e4dd94453c86aa23 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Tue, 27 Apr 2021 11:06:19 +0200 Subject: [PATCH] FX: Fix clipping with compositing enabled --- src/ecompmgr.c | 24 ++++++++++++++++++------ src/ecompmgr.h | 6 ++++-- src/fx.c | 6 +++--- src/x.c | 6 ++++++ src/xwin.h | 1 + 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/ecompmgr.c b/src/ecompmgr.c index 5753c69c..43ee7b3b 100644 --- a/src/ecompmgr.c +++ b/src/ecompmgr.c @@ -256,17 +256,29 @@ static int ECompMgrDetermineOrder(EObj * const *lst, int num, #define REGION_DESTROY(rgn) \ if (rgn != NoXID) { ERegionDestroy(rgn); rgn = NoXID; } -void -ECompMgrWinClipToGC(EObj * eo, GC gc) +EX_SrvRegion +ECompMgrChildClipRegion(void) { + EObj *const *lst, *eoi; + int i, num; EX_SrvRegion rgn = Mode_compmgr.rgn_tmp2; - if (!eo || !eo->cmhook) - return; + if (!Mode_compmgr.active) + return NoXID; ERegionCopy(rgn, Mode_compmgr.rgn_screen); - ERegionSubtract(rgn, eo->cmhook->clip); - XFixesSetGCClipRegion(disp, gc, 0, 0, rgn); + + lst = EobjListStackGet(&num); + for (i = 0; i < num; i++) + { + eoi = lst[i]; + if (eoi->cmhook && eoi->cmhook->shape && + (eoi->type == EOBJ_TYPE_EWIN || eoi->type == EOBJ_TYPE_BUTTON || + eoi->type == EOBJ_TYPE_MISC)) + ERegionSubtract(rgn, eoi->cmhook->shape); + } + + return rgn; } #if !USE_BG_WIN_ON_ALL_DESKS diff --git a/src/ecompmgr.h b/src/ecompmgr.h index f840f15a..0a94c0fd 100644 --- a/src/ecompmgr.h +++ b/src/ecompmgr.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2014 Kim Woelders + * Copyright (C) 2004-2021 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -27,6 +27,7 @@ #include "eobj.h" #include "etypes.h" +#include "xtypes.h" typedef struct { char enable; @@ -60,7 +61,6 @@ void ECompMgrWinChangeOpacity(EObj * eo, unsigned int opacity); void ECompMgrWinChangeShadow(EObj * eo, int shadow); EX_Pixmap ECompMgrWinGetPixmap(const EObj * eo); EX_Picture ECompMgrWinGetAlphaPict(const EObj * eo); -void ECompMgrWinClipToGC(EObj * eo, GC gc); void ECompMgrConfigGet(cfg_composite * cfg); void ECompMgrConfigSet(const cfg_composite * cfg); @@ -70,6 +70,8 @@ int ECompMgrRender(int dt); EX_Window ECompMgrRootWin(void); +EX_SrvRegion ECompMgrChildClipRegion(void); + #else #define ECompMgrIsActive() 0 diff --git a/src/fx.c b/src/fx.c index bb5a81fe..e9a39887 100644 --- a/src/fx.c +++ b/src/fx.c @@ -67,10 +67,10 @@ _FxSetup(FXData * d, unsigned int height) { EObj *bgeo; - bgeo = DeskGetBackgroundObj(DesksGetCurrent()); - if (!d->above) { + bgeo = DeskGetBackgroundObj(DesksGetCurrent()); + d->win = EobjGetWin(bgeo); #if USE_COMPOSITE if (ECompMgrIsActive() && !Mode.wm.window) @@ -89,7 +89,7 @@ _FxSetup(FXData * d, unsigned int height) #if USE_COMPOSITE /* As of composite 0.4 we need to set the clip region */ - ECompMgrWinClipToGC(bgeo, d->gc1); + EGCSetClip(d->gc1, ECompMgrChildClipRegion()); #endif } diff --git a/src/x.c b/src/x.c index 8f0b40c3..b20d7187 100644 --- a/src/x.c +++ b/src/x.c @@ -2171,6 +2171,12 @@ EPictureFillRect(EX_Picture pict, int x, int y, int w, int h, #if USE_COMPOSITE +void +EGCSetClip(GC gc, EX_SrvRegion clip) +{ + XFixesSetGCClipRegion(disp, gc, 0, 0, clip); +} + void EPictureSetClip(EX_Picture pict, EX_SrvRegion clip) { diff --git a/src/xwin.h b/src/xwin.h index e1357439..5422287f 100644 --- a/src/xwin.h +++ b/src/xwin.h @@ -352,6 +352,7 @@ int ERegionIsEmpty(EX_SrvRegion rgn); void ERegionShow(const char *txt, EX_SrvRegion rgn, void (*prf)(const char *fmt, ...)); +void EGCSetClip(GC gc, EX_SrvRegion clip); void EPictureSetClip(EX_Picture pict, EX_SrvRegion clip); EX_Pixmap EWindowGetPixmap(const Win win);