pick the closest icon instead of always a smaller one
This commit is contained in:
parent
d8919a9bf8
commit
8432416d4e
1 changed files with 20 additions and 15 deletions
|
@ -3478,9 +3478,7 @@ gboolean client_focused(ObClient *self)
|
||||||
static ObClientIcon* client_icon_recursive(ObClient *self, gint w, gint h)
|
static ObClientIcon* client_icon_recursive(ObClient *self, gint w, gint h)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
/* si is the smallest image >= req */
|
gulong min_diff, min_i;
|
||||||
/* li is the largest image < req */
|
|
||||||
gulong size, smallest = 0xffffffff, largest = 0, si = 0, li = 0;
|
|
||||||
|
|
||||||
if (!self->nicons) {
|
if (!self->nicons) {
|
||||||
ObClientIcon *parent = NULL;
|
ObClientIcon *parent = NULL;
|
||||||
|
@ -3503,20 +3501,27 @@ static ObClientIcon* client_icon_recursive(ObClient *self, gint w, gint h)
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < self->nicons; ++i) {
|
/* some kind of crappy approximation to find the icon closest in size to
|
||||||
size = self->icons[i].width * self->icons[i].height;
|
what we requested, but icons are generally all the same ratio as
|
||||||
if (size < smallest && size >= (unsigned)(w * h)) {
|
eachother so it's good enough. */
|
||||||
smallest = size;
|
|
||||||
si = i;
|
min_diff = ABS(self->icons[0].width - w) + ABS(self->icons[0].height - h);
|
||||||
}
|
min_i = 0;
|
||||||
if (size > largest && size <= (unsigned)(w * h)) {
|
|
||||||
largest = size;
|
for (i = 1; i < self->nicons; ++i) {
|
||||||
li = i;
|
gulong diff;
|
||||||
|
|
||||||
|
ob_debug("icon %d %d wanted %d %d\n",
|
||||||
|
self->icons[i].width, self->icons[i].height, w, h);
|
||||||
|
diff = ABS(self->icons[0].width - w) + ABS(self->icons[0].height - h);
|
||||||
|
ob_debug("dsize %u\n", diff);
|
||||||
|
if (diff < min_diff) {
|
||||||
|
min_diff = diff;
|
||||||
|
min_i = i;
|
||||||
|
ob_debug("chose it\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (largest == 0) /* didnt find one smaller than the requested size */
|
return &self->icons[min_i];
|
||||||
return &self->icons[si];
|
|
||||||
return &self->icons[li];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ObClientIcon* client_icon(ObClient *self, gint w, gint h)
|
const ObClientIcon* client_icon(ObClient *self, gint w, gint h)
|
||||||
|
|
Loading…
Reference in a new issue