+ client_set_focused(self, FALSE);
+}
+
+gboolean client_focused(Client *self)
+{
+ return self == focus_client;
+}
+
+void client_set_focused(Client *self, gboolean focused)
+{
+ if (focused) {
+ if (focus_client != self)
+ focus_set_client(self);
+ } else {
+ if (focus_client == self)
+ focus_set_client(NULL);
+ }
+
+ /* focus state can affect the stacking layer */
+ client_calc_layer(self);
+
+ engine_frame_adjust_focus(self->frame);
+}
+
+Icon *client_icon(Client *self, int w, int h)
+{
+ int i;
+ /* si is the smallest image >= req */
+ /* li is the largest image < req */
+ unsigned long size, smallest = 0xffffffff, largest = 0, si = 0, li = 0;
+
+ if (!self->nicons) return NULL;
+
+ for (i = 0; i < self->nicons; ++i) {
+ size = self->icons[i].width * self->icons[i].height;
+ if (size < smallest && size >= (unsigned)(w * h)) {
+ smallest = size;
+ si = i;
+ }
+ if (size > largest && size <= (unsigned)(w * h)) {
+ largest = size;
+ li = i;
+ }
+ }
+ if (largest == 0) /* didnt find one smaller than the requested size */
+ return &self->icons[si];
+ return &self->icons[li];