window.c: Handle multiple keyboard foci

Keep a count of number of wl_keyboard focus we have instead of
tracking the more recent wl_keyboard.
diff --git a/clients/window.c b/clients/window.c
index 4e86f06..dd65328 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -145,7 +145,8 @@
 	int resize_needed;
 	int type;
 	int transparent;
-	struct input *keyboard_device;
+	int focus_count;
+
 	enum window_buffer_type buffer_type;
 
 	cairo_surface_t *cairo_surface;
@@ -769,6 +770,12 @@
 	}
 }
 
+int
+window_has_focus(struct window *window)
+{
+	return window->focus_count > 0;
+}
+
 void
 window_flush(struct window *window)
 {
@@ -1514,7 +1521,7 @@
 
 	cr = cairo_create(window->cairo_surface);
 
-	if (window->keyboard_device)
+	if (window->focus_count)
 		flags |= THEME_FRAME_ACTIVE;
 	theme_render_frame(t, cr, widget->allocation.width,
 			   widget->allocation.height, window->title, flags);
@@ -1938,7 +1945,7 @@
 	if (!window)
 		return;
 
-	window->keyboard_device = NULL;
+	window->focus_count--;
 	if (window->keyboard_focus_handler)
 		(*window->keyboard_focus_handler)(window, NULL,
 						  window->user_data);
@@ -2031,11 +2038,10 @@
 	input->keyboard_focus = wl_surface_get_user_data(surface);
 
 	window = input->keyboard_focus;
-	window->keyboard_device = input;
+	window->focus_count++;
 	if (window->keyboard_focus_handler)
 		(*window->keyboard_focus_handler)(window,
-						  window->keyboard_device,
-						  window->user_data);
+						  input, window->user_data);
 }
 
 static void
@@ -2064,7 +2070,7 @@
 
 	input->display->serial = serial;
 	code = key + 8;
-	if (!window || window->keyboard_device != input || !input->xkb.state)
+	if (!window || !input->xkb.state)
 		return;
 
 	num_syms = xkb_key_get_syms(input->xkb.state, code, &syms);