mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-12-17 02:13:18 +00:00
add default transparency for windows and rules for override the transparency
This commit is contained in:
parent
f85d8e79d0
commit
8e17a6da72
10
config.def.h
10
config.def.h
@ -4,15 +4,17 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const float rootcolor[] = {0.3, 0.3, 0.3, 1.0};
|
||||
static const float bordercolor[] = {0.5, 0.5, 0.5, 1.0};
|
||||
static const float focuscolor[] = {1.0, 0.0, 0.0, 1.0};
|
||||
static const double default_alpha = 0.75;
|
||||
|
||||
/* tagging */
|
||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
||||
static const Rule rules[] = {
|
||||
/* app_id title tags mask isfloating monitor */
|
||||
/* app_id title tags mask isfloating alpha monitor */
|
||||
/* examples:
|
||||
{ "Gimp", NULL, 0, 1, -1 },
|
||||
{ "firefox", NULL, 1 << 8, 0, -1 },
|
||||
{ "Gimp", NULL, 0, 1, default_alpha -1 },
|
||||
{ "firefox", NULL, 1 << 8, 0, default_alpha -1 },
|
||||
{ "Alacritty",NULL, 1 << 2, 0, 1.0 -1 },
|
||||
*/
|
||||
};
|
||||
|
||||
@ -76,6 +78,8 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY, XKB_KEY_o, changealpha, {.f = +0.1} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_O, changealpha, {.f = -0.1} },
|
||||
{ MODKEY, XKB_KEY_Return, zoom, {0} },
|
||||
{ MODKEY, XKB_KEY_Tab, view, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
|
||||
|
||||
32
dwl.c
32
dwl.c
@ -111,6 +111,8 @@ typedef struct {
|
||||
int bw;
|
||||
unsigned int tags;
|
||||
int isfloating, isurgent;
|
||||
double alpha;
|
||||
double prevalpha;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
int prevx;
|
||||
int prevy;
|
||||
@ -198,6 +200,7 @@ typedef struct {
|
||||
const char *title;
|
||||
unsigned int tags;
|
||||
int isfloating;
|
||||
double alpha;
|
||||
int monitor;
|
||||
} Rule;
|
||||
|
||||
@ -207,6 +210,7 @@ struct render_data {
|
||||
struct wlr_output *output;
|
||||
struct timespec *when;
|
||||
int x, y; /* layout-relative */
|
||||
double alpha;
|
||||
};
|
||||
|
||||
/* function declarations */
|
||||
@ -221,6 +225,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
static void arrangelayers(Monitor *m);
|
||||
static void axisnotify(struct wl_listener *listener, void *data);
|
||||
static void buttonpress(struct wl_listener *listener, void *data);
|
||||
static void changealpha(const Arg *arg);
|
||||
static void chvt(const Arg *arg);
|
||||
static void cleanup(void);
|
||||
static void cleanupkeyboard(struct wl_listener *listener, void *data);
|
||||
@ -471,6 +476,7 @@ applyrules(Client *c)
|
||||
if ((!r->title || strstr(title, r->title))
|
||||
&& (!r->id || strstr(appid, r->id))) {
|
||||
c->isfloating = r->isfloating;
|
||||
c->alpha = r->alpha;
|
||||
newtags |= r->tags;
|
||||
i = 0;
|
||||
wl_list_for_each(m, &mons, link)
|
||||
@ -678,6 +684,21 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
event->time_msec, event->button, event->state);
|
||||
}
|
||||
|
||||
void
|
||||
changealpha(const Arg *arg)
|
||||
{
|
||||
Client *sel = selclient();
|
||||
|
||||
if (sel) {
|
||||
sel->alpha += arg->f;
|
||||
if (sel->alpha > 1.0)
|
||||
sel->alpha = 1.0;
|
||||
|
||||
if (sel->alpha < 0.1)
|
||||
sel->alpha = 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
chvt(const Arg *arg)
|
||||
{
|
||||
@ -893,6 +914,7 @@ createnotify(struct wl_listener *listener, void *data)
|
||||
c = xdg_surface->data = calloc(1, sizeof(*c));
|
||||
c->surface.xdg = xdg_surface;
|
||||
c->bw = borderpx;
|
||||
c->alpha = default_alpha;
|
||||
|
||||
LISTEN(&xdg_surface->surface->events.commit, &c->commit, commitnotify);
|
||||
LISTEN(&xdg_surface->events.map, &c->map, mapnotify);
|
||||
@ -1033,10 +1055,13 @@ setfullscreen(Client *c, int fullscreen)
|
||||
c->prevy = c->geom.y;
|
||||
c->prevheight = c->geom.height;
|
||||
c->prevwidth = c->geom.width;
|
||||
c->prevalpha = c->alpha;
|
||||
c->alpha = 1;
|
||||
resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0);
|
||||
} else {
|
||||
/* restore previous size instead of arrange for floating windows since
|
||||
* client positions are set by the user and cannot be recalculated */
|
||||
c->alpha = c->prevalpha;
|
||||
resize(c, c->prevx, c->prevy, c->prevwidth, c->prevheight, 0);
|
||||
arrange(c->mon);
|
||||
}
|
||||
@ -1651,7 +1676,7 @@ render(struct wlr_surface *surface, int sx, int sy, void *data)
|
||||
|
||||
/* This takes our matrix, the texture, and an alpha, and performs the actual
|
||||
* rendering on the GPU. */
|
||||
wlr_render_texture_with_matrix(drw, texture, matrix, 1);
|
||||
wlr_render_texture_with_matrix(drw, texture, matrix, rdata->alpha);
|
||||
|
||||
/* This lets the client know that we've displayed that frame and it can
|
||||
* prepare another one now if it likes. */
|
||||
@ -1708,6 +1733,7 @@ renderclients(Monitor *m, struct timespec *now)
|
||||
rdata.when = now;
|
||||
rdata.x = c->geom.x + c->bw;
|
||||
rdata.y = c->geom.y + c->bw;
|
||||
rdata.alpha = c->alpha;
|
||||
client_for_each_surface(c, render, &rdata);
|
||||
}
|
||||
}
|
||||
@ -1722,6 +1748,7 @@ renderlayer(struct wl_list *layer_surfaces, struct timespec *now)
|
||||
.when = now,
|
||||
.x = layersurface->geo.x,
|
||||
.y = layersurface->geo.y,
|
||||
.alpha = 1,
|
||||
};
|
||||
|
||||
wlr_surface_for_each_surface(layersurface->layer_surface->surface,
|
||||
@ -2480,6 +2507,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
|
||||
c->type = xwayland_surface->override_redirect ? X11Unmanaged : X11Managed;
|
||||
c->bw = borderpx;
|
||||
c->isfullscreen = 0;
|
||||
c->alpha = default_alpha;
|
||||
|
||||
/* Listen to the various events it can emit */
|
||||
LISTEN(&xwayland_surface->events.map, &c->map, mapnotify);
|
||||
@ -2528,6 +2556,8 @@ renderindependents(struct wlr_output *output, struct timespec *now)
|
||||
rdata.when = now;
|
||||
rdata.x = c->surface.xwayland->x;
|
||||
rdata.y = c->surface.xwayland->y;
|
||||
rdata.alpha = c->alpha;
|
||||
|
||||
wlr_surface_for_each_surface(c->surface.xwayland->surface, render, &rdata);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user