summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2022-11-15 10:31:15 +0100
committerbakkeby <[email protected]>2022-11-15 10:31:15 +0100
commitdc4e535b253dcb38605443508d17cda2d8323d01 (patch)
tree9ee1ae2dcab24cdfdcf692131a9f43ed021ad93e /patch
parentb4ae62d21a38b475d34c8a1b3a051e41ccda92dd (diff)
downloaddwm-flexipatch-dc4e535b253dcb38605443508d17cda2d8323d01.tar.gz
dwm-flexipatch-dc4e535b253dcb38605443508d17cda2d8323d01.zip
tagpreview: make sure that tagwin is created following configure notify requests ref. #308
Diffstat (limited to 'patch')
-rw-r--r--patch/bar_tagpreview.c119
-rw-r--r--patch/bar_tagpreview.h4
2 files changed, 70 insertions, 53 deletions
diff --git a/patch/bar_tagpreview.c b/patch/bar_tagpreview.c
index c92d05f..27731b0 100644
--- a/patch/bar_tagpreview.c
+++ b/patch/bar_tagpreview.c
@@ -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
@@ -21,20 +48,42 @@ hidetagpreview(Monitor *m)
}
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)
{
int i;
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);
- }
-}
diff --git a/patch/bar_tagpreview.h b/patch/bar_tagpreview.h
index 8129187..44be36d 100644
--- a/patch/bar_tagpreview.h
+++ b/patch/bar_tagpreview.h
@@ -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);