significant image drawing codebase cleanup
This commit is contained in:
parent
00966f7547
commit
c0d8adec85
73
libs/draw.c
73
libs/draw.c
|
@ -573,58 +573,43 @@ void drawmenu_layer(void) {
|
|||
calcoffsets();
|
||||
get_mh();
|
||||
|
||||
// why have an empty line?
|
||||
if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps)) {
|
||||
y -= bh;
|
||||
mh -= bh;
|
||||
// bh must be removed from menu height resizing later
|
||||
if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps) && lines) {
|
||||
y -= bh;
|
||||
}
|
||||
|
||||
if (!protocol && (hideimage || !image)) {
|
||||
#if USEX
|
||||
XResizeWindow(dpy, win, mw - 2 * sp - 2 * borderwidth, mh);
|
||||
drw_resize(drw, mw - 2 * sp - 2 * borderwidth, mh);
|
||||
#endif
|
||||
} else if (protocol && (hideimage || !image)) {
|
||||
#if USEWAYLAND
|
||||
state.width = mw;
|
||||
state.height = mh;
|
||||
if (!hideprompt && !fullscreen) {
|
||||
w = promptw;
|
||||
x = drawprompt(x, y, w);
|
||||
}
|
||||
|
||||
set_layer_size(&state, state.width, state.height);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (!hideinput && !fullscreen) {
|
||||
w = (lines > 0 || !matches) ? mw - x : inputw;
|
||||
x = drawinput(x, y, w);
|
||||
}
|
||||
|
||||
if (!hideprompt && !fullscreen) {
|
||||
w = promptw;
|
||||
x = drawprompt(x, y, w);
|
||||
}
|
||||
if (!hidemode && !fullscreen) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext);
|
||||
|
||||
if (!hideinput && !fullscreen) {
|
||||
w = (lines > 0 || !matches) ? mw - x : inputw;
|
||||
x = drawinput(x, y, w);
|
||||
}
|
||||
// draw the items, this function also calls drawrarrow() and drawlarrow()
|
||||
if (!hideitem) drawitem(x, y, w);
|
||||
|
||||
if (!hidemode && !fullscreen) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext);
|
||||
if (!hidematchcount && !fullscreen) {
|
||||
w = numberWidth;
|
||||
drawnumber(mw - numberWidth - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
||||
}
|
||||
|
||||
// draw the items, this function also calls drawrarrow() and drawlarrow()
|
||||
if (!hideitem) drawitem(x, y, w);
|
||||
if (!hidemode && !fullscreen) {
|
||||
w = modeWidth;
|
||||
drawmode(mw - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
||||
}
|
||||
|
||||
if (!hidematchcount && !fullscreen) {
|
||||
w = numberWidth;
|
||||
drawnumber(mw - numberWidth - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
||||
}
|
||||
|
||||
if (!hidemode && !fullscreen) {
|
||||
w = modeWidth;
|
||||
drawmode(mw - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
||||
}
|
||||
|
||||
if (!hidecaps && !fullscreen) {
|
||||
w = capsWidth;
|
||||
drawcaps(mw - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
||||
}
|
||||
if (!hidecaps && !fullscreen) {
|
||||
w = capsWidth;
|
||||
drawcaps(mw - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
||||
}
|
||||
|
||||
#if USEX
|
||||
drawimage();
|
||||
drw_map(drw, win, 0, 0, mw, mh);
|
||||
drawimage();
|
||||
drw_map(drw, win, 0, 0, mw, mh);
|
||||
#endif
|
||||
}
|
||||
|
|
20
libs/img.c
20
libs/img.c
|
@ -107,16 +107,17 @@ void drawimage(void) {
|
|||
if (height > width)
|
||||
width = height;
|
||||
|
||||
drw_img(drw, leftmargin+(imagewidth-width)/2+xta, wta+leftmargin);
|
||||
drw_img(drw, leftmargin + (imagewidth - width) / 2 + xta, wta + leftmargin);
|
||||
} else if (imageposition == 1 && image) { // bottom mode = 1
|
||||
if (height > width)
|
||||
width = height;
|
||||
drw_img(drw, leftmargin+(imagewidth-width)/2+xta, mh-height-leftmargin);
|
||||
|
||||
drw_img(drw, leftmargin + (imagewidth - width) / 2 + xta, mh - height - leftmargin);
|
||||
} else if (imageposition == 2 && image) { // center mode = 2
|
||||
drw_img(drw, leftmargin+(imagewidth-width)/2+xta, (mh-wta-height)/2+wta);
|
||||
drw_img(drw, leftmargin + (imagewidth - width) / 2 + xta, (mh - wta - height) / 2 + wta);
|
||||
} else if (image) { // top center
|
||||
int minh = MIN(height, mh-bh-leftmargin*2);
|
||||
drw_img(drw, leftmargin+(imagewidth-width)/2+xta, (minh-height)/2+wta+leftmargin);
|
||||
int minh = MIN(height, mh - bh - leftmargin * 2);
|
||||
drw_img(drw, leftmargin + (imagewidth - width) / 2 + xta, (minh - height) / 2 + wta + leftmargin);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -354,7 +355,6 @@ void resizetoimageheight(int imagewidth, int imageheight) {
|
|||
void resizetoimageheight_x11(int imageheight) {
|
||||
int omh = mh, olines = lines;
|
||||
lines = reallines;
|
||||
int wtr = 0;
|
||||
|
||||
int x, y;
|
||||
#if USEXINERAMA
|
||||
|
@ -370,16 +370,8 @@ void resizetoimageheight_x11(int imageheight) {
|
|||
lines = (imageheight + imagegaps * 2) / bh;
|
||||
}
|
||||
|
||||
if (hideprompt && hideinput && hidemode && hidematchcount) {
|
||||
wtr = bh;
|
||||
}
|
||||
|
||||
get_mh();
|
||||
|
||||
if (mh - bh < imageheight + imagegaps * 2) {
|
||||
mh = (imageheight + imagegaps * 2 + bh) - wtr;
|
||||
}
|
||||
|
||||
// init xinerama screens
|
||||
#if USEXINERAMA
|
||||
int i = 0;
|
||||
|
|
|
@ -243,7 +243,8 @@ void buttonpress_wl(uint32_t button, double ex, double ey) {
|
|||
if (!hidemode) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext);
|
||||
if (!hidecaps) capsWidth = pango_caps ? TEXTWM(capstext) : TEXTW(capstext);
|
||||
|
||||
if (!strcmp(capstext, "")) capsWidth = 0; // No caps lock width for no chars
|
||||
if (!strcmp(capstext, ""))
|
||||
capsWidth = 0;
|
||||
|
||||
click = ClickWindow; // Used as a default, will be overriden.
|
||||
|
||||
|
@ -543,14 +544,14 @@ void resizeclient_wl(struct state *state) {
|
|||
reallines = lines;
|
||||
get_mh();
|
||||
|
||||
if (hideprompt && hideinput && hidemode && hidematchcount && hidecaps) {
|
||||
mh -= bh;
|
||||
}
|
||||
|
||||
if (mh == omh) {
|
||||
return;
|
||||
}
|
||||
|
||||
// why have an empty line? when there's nothing to draw there anyway?
|
||||
if (hideprompt && hideinput && hidemode && hidematchcount)
|
||||
mh += bh;
|
||||
|
||||
state->width = mw;
|
||||
state->height = mh;
|
||||
|
||||
|
|
|
@ -98,6 +98,10 @@ void resizeclient_x11(void) {
|
|||
|
||||
get_mh();
|
||||
|
||||
if (hideprompt && hideinput && hidemode && hidematchcount && hidecaps) {
|
||||
mh -= bh;
|
||||
}
|
||||
|
||||
// init xinerama screens
|
||||
#if USEXINERAMA
|
||||
int i = 0;
|
||||
|
@ -157,10 +161,6 @@ void resizeclient_x11(void) {
|
|||
}
|
||||
}
|
||||
|
||||
// why have an empty line? when there's nothing to draw there anyway?
|
||||
if (hideprompt && hideinput && hidemode && hidematchcount)
|
||||
mh += bh;
|
||||
|
||||
// no window/invalid window or menu height we had before is the same as the current window height
|
||||
if (!win || omh == mh) return;
|
||||
|
||||
|
|
|
@ -26,7 +26,9 @@ void buttonpress_x11(XEvent *e) {
|
|||
if (!hidemode) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext);
|
||||
if (!hidecaps) capsWidth = pango_caps ? TEXTWM(capstext) : TEXTW(capstext);
|
||||
|
||||
if (!strcmp(capstext, "")) capsWidth = 0; // no caps lock width for no chars
|
||||
if (!strcmp(capstext, ""))
|
||||
capsWidth = 0;
|
||||
|
||||
if (ev->window != win) return; // if incorrect or wrong window, return
|
||||
|
||||
click = ClickWindow; // clicking anywhere, we use this and override it if we clicked on something specific
|
||||
|
|
Loading…
Reference in a new issue