some more code cleanup
This commit is contained in:
parent
7f2ad4b5d6
commit
a701060f8b
|
@ -14,6 +14,27 @@ void prepare_window_size(void) {
|
|||
return;
|
||||
}
|
||||
|
||||
void get_width(int numwidthchecks, unsigned int minstrlen, unsigned int curstrlen) {
|
||||
struct item *item;
|
||||
unsigned int tmp = 0;
|
||||
|
||||
// get accurate width
|
||||
if (accuratewidth) {
|
||||
for (item = items; !lines && item && item->text; ++item) {
|
||||
curstrlen = strlen(item->text);
|
||||
if (numwidthchecks || minstrlen < curstrlen) {
|
||||
numwidthchecks = MAX(numwidthchecks - 1, 0);
|
||||
minstrlen = MAX(minstrlen, curstrlen);
|
||||
if ((tmp = MIN(TEXTW(item->text), mw/3) > inputw)) {
|
||||
inputw = tmp;
|
||||
if (tmp == mw/3)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void create_window(int x, int y, int w, int h) {
|
||||
XSetWindowAttributes swa;
|
||||
|
||||
|
@ -71,14 +92,14 @@ void resizeclient(void) {
|
|||
#endif
|
||||
XWindowAttributes wa;
|
||||
struct item *item;
|
||||
int itemCount = 0;
|
||||
int ic = 0; // item count
|
||||
|
||||
// walk through all items
|
||||
for (item = items; item && item->text; item++)
|
||||
itemCount++;
|
||||
ic++;
|
||||
|
||||
bh = MAX(drw->font->h, drw->font->h + 2 + lineheight);
|
||||
lines = MIN(itemCount, MAX(lines, 0));
|
||||
lines = MIN(ic, MAX(lines, 0));
|
||||
reallines = lines;
|
||||
|
||||
// resize client to image height
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
static void create_window(int x, int y, int w, int h);
|
||||
static void get_width(int numwidthchecks, unsigned int minstrlen, unsigned int curstrlen);
|
||||
static void prepare_window_size(void);
|
||||
static void set_window(void);
|
||||
static void set_prop(void);
|
||||
|
|
|
@ -4,11 +4,13 @@ void setupdisplay(void) {
|
|||
int j, di;
|
||||
#endif
|
||||
unsigned int du;
|
||||
unsigned int tmp, minstrlen = 0, curstrlen = 0;
|
||||
|
||||
unsigned int minstrlen = 0, curstrlen = 0;
|
||||
int numwidthchecks = 100;
|
||||
struct item *item;
|
||||
|
||||
Window w, dw, *dws;
|
||||
XWindowAttributes wa;
|
||||
|
||||
#if USEXINERAMA
|
||||
XineramaScreenInfo *info;
|
||||
Window pw;
|
||||
|
@ -28,21 +30,7 @@ void setupdisplay(void) {
|
|||
promptw = (prompt && *prompt)
|
||||
? pango_prompt ? TEXTWM(prompt) : TEXTW(prompt) - lrpad / 4 : 0; // prompt width
|
||||
|
||||
// get accurate width
|
||||
if (accuratewidth) {
|
||||
for (item = items; !lines && item && item->text; ++item) {
|
||||
curstrlen = strlen(item->text);
|
||||
if (numwidthchecks || minstrlen < curstrlen) {
|
||||
numwidthchecks = MAX(numwidthchecks - 1, 0);
|
||||
minstrlen = MAX(minstrlen, curstrlen);
|
||||
if ((tmp = MIN(TEXTW(item->text), mw/3) > inputw)) {
|
||||
inputw = tmp;
|
||||
if (tmp == mw/3)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
get_width(numwidthchecks, minstrlen, curstrlen);
|
||||
|
||||
// init xinerama screens
|
||||
#if USEXINERAMA
|
||||
|
|
Loading…
Reference in a new issue