Make window opaque when focused (window option, enabled by default).
Clean up handling of opacity settings, move config options to misc.opacity. Opacity values in configuration are now 0-100 in stead of 0-255. SVN revision: 21722
This commit is contained in:
parent
08e7a93c29
commit
1b8f4b1fe7
|
@ -115,11 +115,12 @@ ADD_MENU_TEXT_ITEM("On Top", __A_CMD, "wop * la 8")
|
|||
END_MENU
|
||||
|
||||
BEGIN_NEW_MENU("WINOPS_OPACITY", "EMPTY")
|
||||
ADD_MENU_TEXT_ITEM("20%", __A_CMD, "wop * op 51")
|
||||
ADD_MENU_TEXT_ITEM("40%", __A_CMD, "wop * op 102")
|
||||
ADD_MENU_TEXT_ITEM("60%", __A_CMD, "wop * op 153")
|
||||
ADD_MENU_TEXT_ITEM("80%", __A_CMD, "wop * op 204")
|
||||
ADD_MENU_TEXT_ITEM("100%", __A_CMD, "wop * op 255")
|
||||
ADD_MENU_TEXT_ITEM("20%", __A_CMD, "wop * op 20")
|
||||
ADD_MENU_TEXT_ITEM("40%", __A_CMD, "wop * op 40")
|
||||
ADD_MENU_TEXT_ITEM("60%", __A_CMD, "wop * op 60")
|
||||
ADD_MENU_TEXT_ITEM("80%", __A_CMD, "wop * op 80")
|
||||
ADD_MENU_TEXT_ITEM("100%", __A_CMD, "wop * op 100")
|
||||
ADD_MENU_TEXT_ITEM("Opaque when focused",__A_CMD, "wop * op opaque_when_focused")
|
||||
ADD_MENU_TEXT_ITEM("Toggle Shadows", __A_CMD, "wop * shadow")
|
||||
END_MENU
|
||||
|
||||
|
|
8
src/E.h
8
src/E.h
|
@ -347,7 +347,6 @@ typedef struct
|
|||
char warp;
|
||||
char show_icons;
|
||||
int icon_size;
|
||||
int opacity;
|
||||
struct
|
||||
{
|
||||
KeySym left, right, up, down, escape, ret;
|
||||
|
@ -358,10 +357,15 @@ typedef struct
|
|||
int mode_move;
|
||||
int mode_resize;
|
||||
int mode_info;
|
||||
int opacity;
|
||||
char update_while_moving;
|
||||
} movres;
|
||||
struct
|
||||
{
|
||||
int movres;
|
||||
int menus;
|
||||
int tooltips;
|
||||
} opacity;
|
||||
struct
|
||||
{
|
||||
char manual;
|
||||
char manual_mouse_pointer;
|
||||
|
|
|
@ -142,12 +142,12 @@ static struct
|
|||
int offset_x, offset_y;
|
||||
struct
|
||||
{
|
||||
unsigned int opacity;
|
||||
int opacity;
|
||||
int radius;
|
||||
} blur;
|
||||
struct
|
||||
{
|
||||
unsigned int opacity;
|
||||
int opacity;
|
||||
} sharp;
|
||||
} shadows;
|
||||
struct
|
||||
|
@ -159,7 +159,7 @@ static struct
|
|||
struct
|
||||
{
|
||||
int mode;
|
||||
unsigned int opacity;
|
||||
int opacity;
|
||||
} override_redirect;
|
||||
} Conf_compmgr;
|
||||
|
||||
|
@ -2209,11 +2209,11 @@ ECompMgrShadowsInit(int mode, int cleanup)
|
|||
{
|
||||
Mode_compmgr.shadow_mode = mode;
|
||||
|
||||
if (Conf_compmgr.shadows.blur.opacity > 100)
|
||||
Conf_compmgr.shadows.blur.opacity = 100;
|
||||
Conf_compmgr.shadows.blur.opacity =
|
||||
OpacityFix(Conf_compmgr.shadows.blur.opacity);
|
||||
Mode_compmgr.opac_blur = .01 * Conf_compmgr.shadows.blur.opacity;
|
||||
if (Conf_compmgr.shadows.sharp.opacity > 100)
|
||||
Conf_compmgr.shadows.sharp.opacity = 100;
|
||||
Conf_compmgr.shadows.sharp.opacity =
|
||||
OpacityFix(Conf_compmgr.shadows.sharp.opacity);
|
||||
Mode_compmgr.opac_sharp = .01 * Conf_compmgr.shadows.sharp.opacity;
|
||||
|
||||
if (gaussianMap)
|
||||
|
@ -2267,13 +2267,10 @@ ECompMgrStart(void)
|
|||
return;
|
||||
Conf_compmgr.enable = Mode_compmgr.active = 1;
|
||||
|
||||
if (Conf_compmgr.override_redirect.opacity > 255)
|
||||
Conf_compmgr.override_redirect.opacity = 100;
|
||||
else if (Conf_compmgr.override_redirect.opacity > 100) /* Fixup - Remove */
|
||||
Conf_compmgr.override_redirect.opacity =
|
||||
(Conf_compmgr.override_redirect.opacity * 100) / 255;
|
||||
Conf_compmgr.override_redirect.opacity =
|
||||
OpacityFix(Conf_compmgr.override_redirect.opacity);
|
||||
Mode_compmgr.opac_or =
|
||||
((Conf_compmgr.override_redirect.opacity * 255) / 100) << 24;
|
||||
OpacityFromPercent(Conf_compmgr.override_redirect.opacity);
|
||||
|
||||
pa.subwindow_mode = IncludeInferiors;
|
||||
pictfmt = XRenderFindVisualFormat(disp, VRoot.vis);
|
||||
|
|
28
src/eobj.c
28
src/eobj.c
|
@ -29,6 +29,34 @@
|
|||
#include "hints.h"
|
||||
#include "xwin.h"
|
||||
|
||||
int
|
||||
OpacityFix(int op)
|
||||
{
|
||||
if (op <= 0 || op > 255)
|
||||
op = 100;
|
||||
else if (op > 100) /* Hack to convert old 0-255 range */
|
||||
op = (100 * op) / 255;
|
||||
return op;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
OpacityFromPercent(int opx)
|
||||
{
|
||||
unsigned int op = (unsigned 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)
|
||||
return 0xffffffff;
|
||||
return op * 42949672;
|
||||
}
|
||||
|
||||
int
|
||||
OpacityToPercent(unsigned int opacity)
|
||||
{
|
||||
return (int)(opacity / 42949672);
|
||||
}
|
||||
|
||||
void
|
||||
EobjSetLayer(EObj * eo, int layer)
|
||||
{
|
||||
|
|
|
@ -175,6 +175,8 @@ void EobjListOrderAdd(EObj * eo);
|
|||
void EobjListOrderDel(EObj * eo);
|
||||
|
||||
/* Hmmm. */
|
||||
unsigned int OpacityExt(int op);
|
||||
int OpacityFix(int op);
|
||||
unsigned int OpacityFromPercent(int op);
|
||||
int OpacityToPercent(unsigned int opacity);
|
||||
|
||||
#endif /* _EOBJ_H_ */
|
||||
|
|
|
@ -1792,25 +1792,15 @@ EwinOpSetBorder(EWin * ewin, int source __UNUSED__, const char *name)
|
|||
Efree(gwins);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
OpacityExt(int op)
|
||||
{
|
||||
/* op is 0-255, extend to 32 bit */
|
||||
/* op = 0 is mapped to 255 (opaque) */
|
||||
if (op <= 0 || op > 255)
|
||||
op = 255;
|
||||
return (op << 24) | (op << 16) | (op << 8) | op;
|
||||
}
|
||||
|
||||
void
|
||||
EwinOpSetOpacity(EWin * ewin, int source __UNUSED__, int opacity)
|
||||
{
|
||||
unsigned int op;
|
||||
|
||||
op = OpacityExt(opacity);
|
||||
op = OpacityFromPercent(opacity);
|
||||
ewin->ewmh.opacity = op;
|
||||
HintsSetWindowOpacity(ewin);
|
||||
EoChangeOpacity(ewin, op);
|
||||
EwinUpdateOpacity(ewin);
|
||||
SnapshotEwinUpdate(ewin, SNAP_USE_OPACITY);
|
||||
}
|
||||
|
||||
|
|
17
src/ewins.c
17
src/ewins.c
|
@ -122,6 +122,7 @@ EwinCreate(Window win, int type)
|
|||
ewin->area_y = -1;
|
||||
|
||||
ewin->ewmh.opacity = 0; /* If 0, ignore */
|
||||
ewin->props.opaque_when_focused = 1;
|
||||
|
||||
return ewin;
|
||||
}
|
||||
|
@ -1611,6 +1612,22 @@ EwinFlagsDecode(EWin * ewin, unsigned int flags)
|
|||
ewin->inh_wm.all = fm.f.inh_wm;
|
||||
}
|
||||
|
||||
void
|
||||
EwinUpdateOpacity(EWin * ewin)
|
||||
{
|
||||
unsigned int opacity;
|
||||
|
||||
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
|
||||
opacity = ewin->ewmh.opacity;
|
||||
|
||||
if (ewin->o.opacity != opacity)
|
||||
EoChangeOpacity(ewin, opacity);
|
||||
}
|
||||
|
||||
/*
|
||||
* Slidein
|
||||
*/
|
||||
|
|
|
@ -109,6 +109,8 @@ struct _ewin
|
|||
|
||||
unsigned showingdesk:1; /* Iconified by show desktop */
|
||||
unsigned animated:1;
|
||||
unsigned moving:1;
|
||||
unsigned resizing:1;
|
||||
unsigned show_coords:1;
|
||||
unsigned maximizing:1;
|
||||
|
||||
|
@ -147,6 +149,7 @@ struct _ewin
|
|||
unsigned autosave:1;
|
||||
unsigned no_border:1; /* Never apply border */
|
||||
unsigned focus_when_mapped:1;
|
||||
unsigned opaque_when_focused:1;
|
||||
} props;
|
||||
EWinInhibit inh_app;
|
||||
EWinInhibit inh_user;
|
||||
|
@ -319,6 +322,7 @@ void EwinRememberPositionGet(EWin * ewin, struct _desk *dsk,
|
|||
int *px, int *py);
|
||||
unsigned int EwinFlagsEncode(const EWin * ewin);
|
||||
void EwinFlagsDecode(EWin * ewin, unsigned int flags);
|
||||
void EwinUpdateOpacity(EWin * ewin);
|
||||
|
||||
void EwinChange(EWin * ewin, unsigned int flag);
|
||||
|
||||
|
|
|
@ -246,6 +246,7 @@ FocusEwinSetActive(EWin * ewin, int active)
|
|||
|
||||
ewin->state.active = active;
|
||||
EwinBorderUpdateState(ewin);
|
||||
EwinUpdateOpacity(ewin);
|
||||
|
||||
FocusGrabsUpdate();
|
||||
|
||||
|
|
18
src/ipc.c
18
src/ipc.c
|
@ -648,13 +648,21 @@ IPC_WinOps(const char *params, Client * c __UNUSED__)
|
|||
break;
|
||||
|
||||
case EWIN_OP_OPACITY:
|
||||
val = OpacityToPercent(ewin->ewmh.opacity);
|
||||
if (!strcmp(param1, "?"))
|
||||
{
|
||||
IpcPrintf("opacity: %u", ewin->ewmh.opacity >> 24);
|
||||
IpcPrintf("opacity: %u", val);
|
||||
goto done;
|
||||
}
|
||||
val = 0xff;
|
||||
sscanf(param1, "%i", &val);
|
||||
if (!strcmp(param1, "opaque_when_focused"))
|
||||
{
|
||||
ewin->props.opaque_when_focused = !ewin->props.opaque_when_focused;
|
||||
}
|
||||
else
|
||||
{
|
||||
sscanf(param1, "%i", &val);
|
||||
val = OpacityFix(val);
|
||||
}
|
||||
EwinOpSetOpacity(ewin, OPSRC_USER, val);
|
||||
break;
|
||||
|
||||
|
@ -994,7 +1002,7 @@ EwinShowInfo(const EWin * ewin)
|
|||
ewin->state.iconified, EoIsSticky(ewin), ewin->state.shaded,
|
||||
ewin->state.docked, ewin->state.state, EoIsShown(ewin),
|
||||
ewin->state.visibility, ewin->state.active, ewin->num_groups,
|
||||
ewin->ewmh.opacity >> 24
|
||||
OpacityToPercent(ewin->ewmh.opacity)
|
||||
#if USE_COMPOSITE
|
||||
, EoGetOpacity(ewin), EoGetShadow(ewin), EoGetNoRedirect(ewin)
|
||||
#endif
|
||||
|
@ -1235,7 +1243,7 @@ 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-255,255=opaque>\n"
|
||||
" win_op <windowid> opacity <1-100(100=opaque),opaque_when_focused>\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"
|
||||
|
|
|
@ -239,7 +239,7 @@ MenuEwinInit(EWin * ewin, void *ptr)
|
|||
EoSetSticky(ewin, 1);
|
||||
EoSetLayer(ewin, 3);
|
||||
EoSetFloating(ewin, 1);
|
||||
ewin->ewmh.opacity = OpacityExt(Conf.menus.opacity);
|
||||
ewin->ewmh.opacity = OpacityFromPercent(Conf.opacity.menus);
|
||||
}
|
||||
|
||||
static void MenuShowMasker(Menu * m);
|
||||
|
@ -2135,7 +2135,6 @@ static const CfgItem MenusCfgItems[] = {
|
|||
CFG_ITEM_BOOL(Conf.menus, warp, 1),
|
||||
CFG_ITEM_BOOL(Conf.menus, show_icons, 1),
|
||||
CFG_ITEM_INT(Conf.menus, icon_size, 16),
|
||||
CFG_ITEM_INT(Conf.menus, opacity, 220),
|
||||
CFG_ITEM_INT(Conf.menus, key.left, XK_Left),
|
||||
CFG_ITEM_INT(Conf.menus, key.right, XK_Right),
|
||||
CFG_ITEM_INT(Conf.menus, key.up, XK_Up),
|
||||
|
|
|
@ -119,7 +119,10 @@ static const CfgItem MiscCfgItems[] = {
|
|||
CFG_ITEM_INT(Conf, movres.mode_resize, 2),
|
||||
CFG_ITEM_INT(Conf, movres.mode_info, 1),
|
||||
CFG_ITEM_INT(Conf, movres.update_while_moving, 0),
|
||||
CFG_ITEM_INT(Conf, movres.opacity, 150),
|
||||
|
||||
CFG_ITEM_INT(Conf, opacity.menus, 85),
|
||||
CFG_ITEM_INT(Conf, opacity.movres, 60),
|
||||
CFG_ITEM_INT(Conf, opacity.tooltips, 80),
|
||||
|
||||
CFG_ITEM_BOOL(Conf, place.manual, 0),
|
||||
CFG_ITEM_BOOL(Conf, place.manual_mouse_pointer, 0),
|
||||
|
|
|
@ -98,9 +98,10 @@ ActionMoveStart(EWin * ewin, int grab, char constrained, int nogroup)
|
|||
for (i = 0; i < num; i++)
|
||||
{
|
||||
EwinShapeSet(gwins[i]);
|
||||
ewin->state.moving = 1;
|
||||
EwinFloatAt(gwins[i], EoGetX(gwins[i]), EoGetY(gwins[i]));
|
||||
if (Mode_mr.mode == 0)
|
||||
EoChangeOpacity(gwins[i], OpacityExt(Conf.movres.opacity));
|
||||
EwinUpdateOpacity(gwins[i]);
|
||||
}
|
||||
Efree(gwins);
|
||||
|
||||
|
@ -154,8 +155,9 @@ ActionMoveEnd(EWin * ewin)
|
|||
EwinUnfloatAt(ewin, d2,
|
||||
ewin->shape_x - (EoGetX(d2) - EoGetX(d1)),
|
||||
ewin->shape_y - (EoGetY(d2) - EoGetY(d1)));
|
||||
ewin->state.moving = 0;
|
||||
if (Mode_mr.mode == 0)
|
||||
EoChangeOpacity(ewin, ewin->ewmh.opacity);
|
||||
EwinUpdateOpacity(ewin);
|
||||
}
|
||||
|
||||
Efree(gwins);
|
||||
|
@ -269,6 +271,7 @@ ActionResizeStart(EWin * ewin, int grab, int hv)
|
|||
|
||||
SoundPlay("SOUND_RESIZE_START");
|
||||
|
||||
ewin->state.resizing = 1;
|
||||
if (Conf.movres.mode_resize < 0 || Conf.movres.mode_resize > 4)
|
||||
Conf.movres.mode_resize = 0;
|
||||
if (Conf.movres.mode_resize > 0)
|
||||
|
@ -280,7 +283,7 @@ ActionResizeStart(EWin * ewin, int grab, int hv)
|
|||
}
|
||||
else
|
||||
{
|
||||
EoChangeOpacity(ewin, OpacityExt(Conf.movres.opacity));
|
||||
EwinUpdateOpacity(ewin);
|
||||
}
|
||||
|
||||
if (grab)
|
||||
|
@ -385,13 +388,14 @@ ActionResizeEnd(EWin * ewin)
|
|||
if (!ewin)
|
||||
goto done;
|
||||
|
||||
ewin->state.resizing = 0;
|
||||
ewin->state.show_coords = 0;
|
||||
DrawEwinShape(ewin, Conf.movres.mode_resize, ewin->shape_x, ewin->shape_y,
|
||||
ewin->client.w, ewin->client.h, 2);
|
||||
|
||||
if (Conf.movres.mode_resize == 0)
|
||||
{
|
||||
EoChangeOpacity(ewin, ewin->ewmh.opacity);
|
||||
EwinUpdateOpacity(ewin);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
21
src/snaps.c
21
src/snaps.c
|
@ -62,6 +62,7 @@ struct _snapshot
|
|||
char skipwinlist;
|
||||
#if USE_COMPOSITE
|
||||
int opacity;
|
||||
char opaque_when_focused;
|
||||
char shadow;
|
||||
#endif
|
||||
};
|
||||
|
@ -457,7 +458,8 @@ SnapEwinGroups(Snapshot * sn, const EWin * ewin, char onoff)
|
|||
static void
|
||||
SnapEwinOpacity(Snapshot * sn, const EWin * ewin)
|
||||
{
|
||||
sn->opacity = ewin->ewmh.opacity >> 24;
|
||||
sn->opacity = OpacityToPercent(ewin->ewmh.opacity);
|
||||
sn->opaque_when_focused = ewin->props.opaque_when_focused;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1164,7 +1166,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\n", sn->opacity);
|
||||
fprintf(f, "OPACITY: %i %i\n", sn->opacity, sn->opaque_when_focused);
|
||||
if (sn->use_flags & SNAP_USE_SHADOW)
|
||||
fprintf(f, "SHADOW: %i\n", sn->shadow);
|
||||
#endif
|
||||
|
@ -1390,7 +1392,11 @@ LoadSnapInfo(void)
|
|||
else if (!strcmp(buf, "OPACITY"))
|
||||
{
|
||||
sn->use_flags |= SNAP_USE_OPACITY;
|
||||
sn->opacity = atoi(s);
|
||||
a = 100;
|
||||
b = 1;
|
||||
sscanf(s, "%i %i", &a, &b);
|
||||
sn->opacity = a;
|
||||
sn->opaque_when_focused = b;
|
||||
}
|
||||
else if (!strcmp(buf, "SHADOW"))
|
||||
{
|
||||
|
@ -1431,7 +1437,8 @@ SnapshotEwinApply(EWin * ewin)
|
|||
use_flags = sn->use_flags;
|
||||
/* If restarting don't override stuff set in attributes/properties */
|
||||
if (ewin->state.identified)
|
||||
use_flags &= SNAP_USE_LAYER | SNAP_USE_SHADOW | SNAP_USE_GROUPS;
|
||||
use_flags &= SNAP_USE_LAYER | SNAP_USE_SHADOW | SNAP_USE_GROUPS |
|
||||
SNAP_USE_OPACITY;
|
||||
|
||||
if (use_flags & SNAP_USE_STICKY)
|
||||
EoSetSticky(ewin, sn->sticky);
|
||||
|
@ -1503,7 +1510,11 @@ SnapshotEwinApply(EWin * ewin)
|
|||
|
||||
#if USE_COMPOSITE
|
||||
if (use_flags & SNAP_USE_OPACITY)
|
||||
ewin->ewmh.opacity = OpacityExt(sn->opacity);
|
||||
{
|
||||
sn->opacity = OpacityFix(sn->opacity);
|
||||
ewin->ewmh.opacity = OpacityFromPercent(sn->opacity);
|
||||
ewin->props.opaque_when_focused = sn->opaque_when_focused;
|
||||
}
|
||||
|
||||
if (use_flags & SNAP_USE_SHADOW)
|
||||
EoSetShadow(ewin, sn->shadow);
|
||||
|
|
|
@ -40,7 +40,6 @@ static struct
|
|||
char enable;
|
||||
char showroottooltip;
|
||||
int delay; /* milliseconds */
|
||||
unsigned int opacity;
|
||||
} Conf_tooltips;
|
||||
|
||||
static struct
|
||||
|
@ -104,7 +103,7 @@ TooltipCreate(const char *name, ImageClass * ic0, ImageClass * ic1,
|
|||
|
||||
eo = EobjWindowCreate(EOBJ_TYPE_MISC, -50, -100, wh, wh, 1, name);
|
||||
ImageclassIncRefcount(tt->iclass[i]);
|
||||
EobjChangeOpacity(eo, OpacityExt(Conf_tooltips.opacity));
|
||||
EobjChangeOpacity(eo, OpacityFromPercent(Conf.opacity.tooltips));
|
||||
tt->win[i] = eo;
|
||||
}
|
||||
tt->iwin = ECreateWindow(tt->TTWIN->win, 0, 0, 1, 1, 0);
|
||||
|
@ -913,7 +912,6 @@ static const CfgItem TooltipsCfgItems[] = {
|
|||
CFG_ITEM_BOOL(Conf_tooltips, enable, 1),
|
||||
CFG_ITEM_BOOL(Conf_tooltips, showroottooltip, 1),
|
||||
CFG_ITEM_INT(Conf_tooltips, delay, 1500),
|
||||
CFG_ITEM_INT(Conf_tooltips, opacity, 200),
|
||||
};
|
||||
#define N_CFG_ITEMS (sizeof(TooltipsCfgItems)/sizeof(CfgItem))
|
||||
|
||||
|
|
|
@ -733,7 +733,8 @@ WindowMatchEwinOpsAction(EWin * ewin, int op, const char *args)
|
|||
break;
|
||||
|
||||
case EWIN_OP_OPACITY:
|
||||
ewin->ewmh.opacity = OpacityExt(atoi(args));
|
||||
a = atoi(args);
|
||||
ewin->ewmh.opacity = OpacityFromPercent(OpacityFix(a));
|
||||
break;
|
||||
|
||||
case EWIN_OP_SKIP_LISTS:
|
||||
|
|
Loading…
Reference in New Issue