mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
tagpreview: make sure that tagwin is created following configure notify requests ref. #308
This commit is contained in:
parent
b4ae62d21a
commit
dc4e535b25
6
dwm.c
6
dwm.c
@ -1483,6 +1483,9 @@ configurenotify(XEvent *e)
|
||||
#endif // !FAKEFULLSCREEN_PATCH
|
||||
for (bar = m->bar; bar; bar = bar->next)
|
||||
XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
|
||||
#if BAR_TAGPREVIEW_PATCH
|
||||
createpreview(m);
|
||||
#endif // BAR_TAGPREVIEW_PATCH
|
||||
}
|
||||
focus(NULL);
|
||||
arrange(NULL);
|
||||
@ -3770,9 +3773,6 @@ setup(void)
|
||||
|
||||
updatebars();
|
||||
updatestatus();
|
||||
#if BAR_TAGPREVIEW_PATCH
|
||||
updatepreview();
|
||||
#endif // BAR_TAGPREVIEW_PATCH
|
||||
|
||||
/* supporting window for NetWMCheck */
|
||||
wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0);
|
||||
|
@ -1,16 +1,43 @@
|
||||
#include <Imlib2.h>
|
||||
|
||||
void
|
||||
showtagpreview(int tag, int x, int y)
|
||||
createpreview(Monitor *m)
|
||||
{
|
||||
if (selmon->tagmap[tag]) {
|
||||
XSetWindowBackgroundPixmap(dpy, selmon->tagwin, selmon->tagmap[tag]);
|
||||
XCopyArea(dpy, selmon->tagmap[tag], selmon->tagwin, drw->gc, 0, 0, selmon->mw / scalepreview, selmon->mh / scalepreview, 0, 0);
|
||||
XMoveWindow(dpy, selmon->tagwin, x, y);
|
||||
XSync(dpy, False);
|
||||
XMapWindow(dpy, selmon->tagwin);
|
||||
} else
|
||||
XUnmapWindow(dpy, selmon->tagwin);
|
||||
if (m->tagwin) {
|
||||
XMoveResizeWindow(
|
||||
dpy, m->tagwin,
|
||||
m->mx,
|
||||
m->bar->by + bh,
|
||||
m->mw / scalepreview,
|
||||
m->mh / scalepreview
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
XSetWindowAttributes wa = {
|
||||
.override_redirect = True,
|
||||
#if BAR_ALPHA_PATCH
|
||||
.background_pixel = 0,
|
||||
.border_pixel = 0,
|
||||
.colormap = cmap,
|
||||
#else
|
||||
.background_pixmap = ParentRelative,
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
.event_mask = ButtonPressMask|ExposureMask
|
||||
};
|
||||
|
||||
m->tagwin = XCreateWindow(dpy, root, m->wx, m->bar->by + bh, m->mw / scalepreview, m->mh / scalepreview, 0,
|
||||
#if BAR_ALPHA_PATCH
|
||||
depth, CopyFromParent, visual,
|
||||
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa
|
||||
#else
|
||||
DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
);
|
||||
XDefineCursor(dpy, m->tagwin, cursor[CurNormal]->cursor);
|
||||
XMapRaised(dpy, m->tagwin);
|
||||
XUnmapWindow(dpy, m->tagwin);
|
||||
}
|
||||
|
||||
void
|
||||
@ -20,6 +47,24 @@ hidetagpreview(Monitor *m)
|
||||
XUnmapWindow(dpy, m->tagwin);
|
||||
}
|
||||
|
||||
void
|
||||
showtagpreview(int tag, int x, int y)
|
||||
{
|
||||
Monitor *m = selmon;
|
||||
|
||||
if (!m->tagwin)
|
||||
return;
|
||||
|
||||
if (m->tagmap[tag]) {
|
||||
XSetWindowBackgroundPixmap(dpy, m->tagwin, m->tagmap[tag]);
|
||||
XCopyArea(dpy, m->tagmap[tag], m->tagwin, drw->gc, 0, 0, m->mw / scalepreview, m->mh / scalepreview, 0, 0);
|
||||
XMoveWindow(dpy, m->tagwin, x, y);
|
||||
XSync(dpy, False);
|
||||
XMapWindow(dpy, m->tagwin);
|
||||
} else
|
||||
XUnmapWindow(dpy, m->tagwin);
|
||||
}
|
||||
|
||||
void
|
||||
tagpreviewswitchtag(void)
|
||||
{
|
||||
@ -27,14 +72,18 @@ tagpreviewswitchtag(void)
|
||||
unsigned int occ = 0;
|
||||
Client *c;
|
||||
Imlib_Image image;
|
||||
Monitor *m = selmon;
|
||||
|
||||
for (c = selmon->clients; c; c = c->next)
|
||||
if (!m->tagwin)
|
||||
createpreview(m);
|
||||
|
||||
for (c = m->clients; c; c = c->next)
|
||||
occ |= c->tags;
|
||||
for (i = 0; i < NUMTAGS; i++) {
|
||||
if (selmon->tagset[selmon->seltags] & 1 << i) {
|
||||
if (selmon->tagmap[i] != 0) {
|
||||
XFreePixmap(dpy, selmon->tagmap[i]);
|
||||
selmon->tagmap[i] = 0;
|
||||
if (m->tagset[m->seltags] & 1 << i) {
|
||||
if (m->tagmap[i] != 0) {
|
||||
XFreePixmap(dpy, m->tagmap[i]);
|
||||
m->tagmap[i] = 0;
|
||||
}
|
||||
if (occ & 1 << i) {
|
||||
image = imlib_create_image(sw, sh);
|
||||
@ -48,48 +97,16 @@ tagpreviewswitchtag(void)
|
||||
imlib_context_set_visual(DefaultVisual(dpy, screen));
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
imlib_context_set_drawable(root);
|
||||
imlib_copy_drawable_to_image(0, selmon->mx, selmon->my, selmon->mw ,selmon->mh, 0, 0, 1);
|
||||
imlib_copy_drawable_to_image(0, m->mx, m->my, m->mw ,m->mh, 0, 0, 1);
|
||||
#if BAR_ALPHA_PATCH
|
||||
selmon->tagmap[i] = XCreatePixmap(dpy, selmon->tagwin, selmon->mw / scalepreview, selmon->mh / scalepreview, depth);
|
||||
m->tagmap[i] = XCreatePixmap(dpy, m->tagwin, m->mw / scalepreview, m->mh / scalepreview, depth);
|
||||
#else
|
||||
selmon->tagmap[i] = XCreatePixmap(dpy, selmon->tagwin, selmon->mw / scalepreview, selmon->mh / scalepreview, DefaultDepth(dpy, screen));
|
||||
m->tagmap[i] = XCreatePixmap(dpy, m->tagwin, m->mw / scalepreview, m->mh / scalepreview, DefaultDepth(dpy, screen));
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
imlib_context_set_drawable(selmon->tagmap[i]);
|
||||
imlib_render_image_part_on_drawable_at_size(0, 0, selmon->mw, selmon->mh, 0, 0, selmon->mw / scalepreview, selmon->mh / scalepreview);
|
||||
imlib_context_set_drawable(m->tagmap[i]);
|
||||
imlib_render_image_part_on_drawable_at_size(0, 0, m->mw, m->mh, 0, 0, m->mw / scalepreview, m->mh / scalepreview);
|
||||
imlib_free_image();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
updatepreview(void)
|
||||
{
|
||||
Monitor *m;
|
||||
|
||||
XSetWindowAttributes wa = {
|
||||
.override_redirect = True,
|
||||
#if BAR_ALPHA_PATCH
|
||||
.background_pixel = 0,
|
||||
.border_pixel = 0,
|
||||
.colormap = cmap,
|
||||
#else
|
||||
.background_pixmap = ParentRelative,
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
.event_mask = ButtonPressMask|ExposureMask
|
||||
};
|
||||
for (m = mons; m; m = m->next) {
|
||||
m->tagwin = XCreateWindow(dpy, root, m->wx, m->bar->by + bh, m->mw / 4, m->mh / 4, 0,
|
||||
#if BAR_ALPHA_PATCH
|
||||
depth, CopyFromParent, visual,
|
||||
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa
|
||||
#else
|
||||
DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa
|
||||
#endif // BAR_ALPHA_PATCH
|
||||
);
|
||||
XDefineCursor(dpy, m->tagwin, cursor[CurNormal]->cursor);
|
||||
XMapRaised(dpy, m->tagwin);
|
||||
XUnmapWindow(dpy, m->tagwin);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
static void showtagpreview(int tag, int x, int y);
|
||||
static void createpreview(Monitor *m);
|
||||
static void hidetagpreview(Monitor *m);
|
||||
static void showtagpreview(int tag, int x, int y);
|
||||
static void tagpreviewswitchtag(void);
|
||||
static void updatepreview(void);
|
||||
|
Loading…
Reference in New Issue
Block a user