forked from e16/e16
1
0
Fork 0

Enable setting focused/non-focused opacity independently.

- Based on patch from Grant Wier.


SVN revision: 26934
This commit is contained in:
Kim Woelders 2006-11-03 23:44:32 +00:00
parent ebf31bd1e5
commit d8dcbc390b
11 changed files with 95 additions and 32 deletions

View File

@ -40,6 +40,11 @@ MouseDouble A 1 wop * shade
MouseDown A 2 wop * sz ptr
MouseDouble A 2 wop * th available
MouseDown A 3 menus show WINOPS_MENU
# May be used to control opacity with mouse
#MouseDown A 4 wop * focused_opacity +10
#MouseDown A 5 wop * focused_opacity -10
#MouseDown AC 4 wop * opacity +10
#MouseDown AC 5 wop * opacity -10
# Mouse presses on the desktop background ....

View File

@ -2198,10 +2198,10 @@ ECompMgrShadowsInit(int mode, int cleanup)
Mode_compmgr.shadow_mode = mode;
Conf_compmgr.shadows.blur.opacity =
OpacityFix(Conf_compmgr.shadows.blur.opacity);
OpacityFix(Conf_compmgr.shadows.blur.opacity, 100);
Mode_compmgr.opac_blur = .01 * Conf_compmgr.shadows.blur.opacity;
Conf_compmgr.shadows.sharp.opacity =
OpacityFix(Conf_compmgr.shadows.sharp.opacity);
OpacityFix(Conf_compmgr.shadows.sharp.opacity, 100);
Mode_compmgr.opac_sharp = .01 * Conf_compmgr.shadows.sharp.opacity;
if (gaussianMap)
@ -2256,7 +2256,7 @@ ECompMgrStart(void)
Conf_compmgr.enable = Mode_compmgr.active = 1;
Conf_compmgr.override_redirect.opacity =
OpacityFix(Conf_compmgr.override_redirect.opacity);
OpacityFix(Conf_compmgr.override_redirect.opacity, 100);
pa.subwindow_mode = IncludeInferiors;
pictfmt = XRenderFindVisualFormat(disp, VRoot.vis);

View File

@ -30,9 +30,11 @@
#include "xwin.h"
int
OpacityFix(int op)
OpacityFix(int op, int op_0)
{
if (op <= 0 || op > 255)
if (op <= 0)
op = op_0;
else if (op > 255)
op = 100;
else if (op > 100) /* Hack to convert old 0-255 range */
op = (100 * op) / 255;
@ -46,7 +48,7 @@ OpacityFromPercent(int opx)
/* op is 0-100, extend to 32 bit */
/* op <= 0 and op > 100 is mapped to 100 (opaque) */
if (op == 0 || op >= 100)
if (op >= 100)
return 0xffffffff;
return op * 42949672;
}

View File

@ -181,7 +181,7 @@ void EobjListOrderAdd(EObj * eo);
void EobjListOrderDel(EObj * eo);
/* Hmmm. */
int OpacityFix(int op);
int OpacityFix(int op, int op_0);
unsigned int OpacityFromPercent(int op);
int OpacityToPercent(unsigned int opacity);

View File

@ -45,6 +45,7 @@ static const WinOp winops[] = {
{"kill", 0, 1, 0, EWIN_OP_KILL},
{"iconify", 2, 1, 1, EWIN_OP_ICONIFY},
{"opacity", 2, 1, 1, EWIN_OP_OPACITY},
{"focused_opacity", 0, 1, 1, EWIN_OP_FOCUSED_OPACITY},
{"shadow", 0, 1, 1, EWIN_OP_SHADOW}, /* Place before "shade" */
{"shade", 2, 1, 1, EWIN_OP_SHADE},
{"stick", 2, 1, 1, EWIN_OP_STICK},
@ -1839,6 +1840,17 @@ EwinOpSetOpacity(EWin * ewin, int source __UNUSED__, int opacity)
SnapshotEwinUpdate(ewin, SNAP_USE_OPACITY);
}
void
EwinOpSetFocusedOpacity(EWin * ewin, int source __UNUSED__, int opacity)
{
unsigned int op;
op = OpacityFromPercent(opacity);
ewin->props.focused_opacity = op;
EwinUpdateOpacity(ewin);
SnapshotEwinUpdate(ewin, SNAP_USE_OPACITY);
}
void
EwinOpMoveToDesk(EWin * ewin, int source __UNUSED__, Desk * dsk, int inc)
{

View File

@ -55,6 +55,7 @@ typedef enum
EWIN_OP_LOWER,
EWIN_OP_OPACITY,
EWIN_OP_FOCUSED_OPACITY,
EWIN_OP_SNAP,

View File

@ -134,7 +134,7 @@ EwinCreate(int type)
ewin->place.gravity = -1;
ewin->ewmh.opacity = 0; /* If 0, ignore */
ewin->props.opaque_when_focused = 1;
ewin->props.focused_opacity = 0;
return ewin;
}
@ -1798,11 +1798,12 @@ EwinUpdateOpacity(EWin * ewin)
{
unsigned int opacity;
opacity = 0;
if (ewin->state.moving || ewin->state.resizing)
opacity = OpacityFromPercent(Conf.opacity.movres);
else if (ewin->state.active && ewin->props.opaque_when_focused)
opacity = 0xffffffff;
else
else if (ewin->state.active)
opacity = ewin->props.focused_opacity;
if (opacity == 0)
opacity = ewin->ewmh.opacity;
EoChangeOpacity(ewin, opacity);

View File

@ -139,7 +139,7 @@ struct _ewin
unsigned autosave:1;
unsigned no_border:1; /* Never apply border */
unsigned focus_when_mapped:1;
unsigned opaque_when_focused:1;
unsigned int focused_opacity;
} props;
EWinInhibit inh_app;
EWinInhibit inh_user;
@ -394,6 +394,8 @@ void EwinOpShade(EWin * ewin, int source, int on);
void EwinOpSetLayer(EWin * ewin, int source, int layer);
void EwinOpSetBorder(EWin * ewin, int source, const char *name);
void EwinOpSetOpacity(EWin * ewin, int source, int opacity);
void EwinOpSetFocusedOpacity(EWin * ewin, int source,
int opacity);
void EwinOpMoveToDesk(EWin * ewin, int source, Desk * dsk,
int inc);
void EwinOpFullscreen(EWin * ewin, int source, int on);

View File

@ -44,6 +44,17 @@ static const char NoText[] = "-NONE-";
static size_t bufsiz;
static char *bufptr;
static void
OpacityTimeout(int val, void *data __UNUSED__)
{
EWin *ewin;
ewin = EwinFindByClient(val);
if (ewin)
if (ewin->state.active)
EoChangeOpacity(ewin, ewin->props.focused_opacity);
}
static void
IpcPrintInit(void)
{
@ -780,22 +791,40 @@ IpcWinop(const WinOp * wop, EWin * ewin, const char *prm)
break;
case EWIN_OP_OPACITY:
val = OpacityToPercent(ewin->ewmh.opacity);
a = OpacityToPercent(ewin->ewmh.opacity);
if (!strcmp(param1, "?"))
{
IpcPrintf("opacity: %u", val);
IpcPrintf("opacity: %u", a);
goto done;
}
if (!strcmp(param1, "opaque_when_focused"))
b = a;
sscanf(param1, "%i", &b);
if ((param1[0] == '+') || (param1[0] == '-'))
b += a;
a = (b < 0) ? 1 : (b > 100) ? 100 : b;
EwinOpSetOpacity(ewin, OPSRC_USER, a);
if (ewin->state.active)
{
ewin->props.opaque_when_focused = !ewin->props.opaque_when_focused;
EoChangeOpacity(ewin, OpacityFromPercent(a));
if (ewin->props.focused_opacity)
DoIn("OPACITY_TIMEOUT", 0.001 * 700, OpacityTimeout,
EwinGetClientXwin(ewin), NULL);
}
else
break;
case EWIN_OP_FOCUSED_OPACITY:
a = OpacityToPercent(ewin->props.focused_opacity);
if (!strcmp(param1, "?"))
{
sscanf(param1, "%i", &val);
val = OpacityFix(val);
IpcPrintf("focused_opacity: %u", a);
goto done;
}
EwinOpSetOpacity(ewin, OPSRC_USER, val);
b = a;
sscanf(param1, "%i", &b);
if ((param1[0] == '+') || (param1[0] == '-'))
b += a;
a = (b < 0) ? 0 : (b > 100) ? 100 : b;
EwinOpSetFocusedOpacity(ewin, OPSRC_USER, a);
break;
case EWIN_OP_SNAP:
@ -1140,7 +1169,8 @@ EwinShowInfo(const EWin * ewin)
"State %i Shown %i Visibility %i Active %i\n"
"Member of groups %i\n"
#if USE_COMPOSITE
"Opacity %3i(%x) Shadow %i Fade %i NoRedirect %i\n"
"Opacity %3i(%x) Focused Opacity %3i\n"
"Shadow %i Fade %i NoRedirect %i\n"
#else
"Opacity %3i\n"
#endif
@ -1186,8 +1216,9 @@ EwinShowInfo(const EWin * ewin)
ewin->state.visibility, ewin->state.active, ewin->num_groups,
OpacityToPercent(ewin->ewmh.opacity)
#if USE_COMPOSITE
, EoGetOpacity(ewin), EoGetShadow(ewin), EoGetFade(ewin),
EoGetNoRedirect(ewin)
, EoGetOpacity(ewin),
OpacityToPercent(ewin->props.focused_opacity), EoGetShadow(ewin),
EoGetFade(ewin), EoGetNoRedirect(ewin)
#endif
);
}
@ -1428,7 +1459,8 @@ static const IpcItem IPCArray[] = {
" win_op <windowid> <fullscreen/zoom>\n"
" win_op <windowid> layer <0-100,4=normal>\n"
" win_op <windowid> <raise/lower>\n"
" win_op <windowid> opacity <1-100(100=opaque),opaque_when_focused>\n"
" win_op <windowid> opacity <1-100(100=opaque)>\n"
" win_op <windowid> focused_opacity <0-100(0=follow opacity, 100=opaque)>\n"
" win_op <windowid> snap <what>\n"
" <what>: all, none, border, command, desktop, dialog, group, icon,\n"
" layer, location, opacity, shade, shadow, size, sticky\n"

View File

@ -65,7 +65,7 @@ struct _snapshot
char skipwinlist;
#if USE_COMPOSITE
int opacity;
char opaque_when_focused;
int focused_opacity;
char shadow;
#endif
};
@ -462,7 +462,7 @@ static void
SnapEwinOpacity(Snapshot * sn, const EWin * ewin)
{
sn->opacity = OpacityToPercent(ewin->ewmh.opacity);
sn->opaque_when_focused = ewin->props.opaque_when_focused;
sn->focused_opacity = OpacityToPercent(ewin->props.focused_opacity);
}
static void
@ -1158,7 +1158,7 @@ Real_SaveSnapInfo(int dumval __UNUSED__, void *dumdat __UNUSED__)
fprintf(f, "FLAGS: %#x\n", sn->flags);
#if USE_COMPOSITE
if (sn->use_flags & SNAP_USE_OPACITY)
fprintf(f, "OPACITY: %i %i\n", sn->opacity, sn->opaque_when_focused);
fprintf(f, "OPACITY: %i %i\n", sn->opacity, sn->focused_opacity);
if (sn->use_flags & SNAP_USE_SHADOW)
fprintf(f, "SHADOW: %i\n", sn->shadow);
#endif
@ -1385,10 +1385,12 @@ LoadSnapInfo(void)
{
sn->use_flags |= SNAP_USE_OPACITY;
a = 100;
b = 1;
b = 100;
sscanf(s, "%i %i", &a, &b);
if (b == 1)
b = 100; /* BW compat - focused is opaque */
sn->opacity = a;
sn->opaque_when_focused = b;
sn->focused_opacity = b;
}
else if (!strcmp(buf, "SHADOW"))
{
@ -1503,9 +1505,10 @@ SnapshotEwinApply(EWin * ewin)
#if USE_COMPOSITE
if (use_flags & SNAP_USE_OPACITY)
{
sn->opacity = OpacityFix(sn->opacity);
sn->opacity = OpacityFix(sn->opacity, 100);
sn->focused_opacity = OpacityFix(sn->focused_opacity, 0);
ewin->ewmh.opacity = OpacityFromPercent(sn->opacity);
ewin->props.opaque_when_focused = sn->opaque_when_focused;
ewin->props.focused_opacity = OpacityFromPercent(sn->focused_opacity);
}
if (use_flags & SNAP_USE_SHADOW)

View File

@ -717,7 +717,12 @@ WindowMatchEwinOpsAction(EWin * ewin, int op, const char *args)
case EWIN_OP_OPACITY:
a = atoi(args);
ewin->ewmh.opacity = OpacityFromPercent(OpacityFix(a));
ewin->ewmh.opacity = OpacityFromPercent(OpacityFix(a, 100));
break;
case EWIN_OP_FOCUSED_OPACITY:
a = atoi(args);
ewin->props.focused_opacity = OpacityFromPercent(OpacityFix(a, 0));
break;
case EWIN_OP_SKIP_LISTS: