+ if (set_focus && assignment_for(cwindow, A_NO_FOCUS) != NULL) {
+ /* The first window on a workspace should always be focused. We have to
+ * compare with == 1 because the container has already been inserted at
+ * this point. */
+ if (con_num_windows(ws) == 1) {
+ DLOG("This is the first window on this workspace, ignoring no_focus.\n");
+ } else {
+ DLOG("no_focus was set for con = %p, not setting focus.\n", nc);
+ set_focus = false;
+ }
+ }
+
+ if (set_focus) {
+ DLOG("Checking con = %p for _NET_WM_USER_TIME.\n", nc);
+
+ uint32_t *wm_user_time;
+ xcb_get_property_reply_t *wm_user_time_reply = xcb_get_property_reply(conn, wm_user_time_cookie, NULL);
+ if (wm_user_time_reply != NULL && xcb_get_property_value_length(wm_user_time_reply) != 0 &&
+ (wm_user_time = xcb_get_property_value(wm_user_time_reply)) &&
+ wm_user_time[0] == 0) {
+ DLOG("_NET_WM_USER_TIME set to 0, not focusing con = %p.\n", nc);
+ set_focus = false;
+ }
+
+ FREE(wm_user_time_reply);
+ } else {
+ xcb_discard_reply(conn, wm_user_time_cookie.sequence);
+ }
+
+ if (set_focus) {
+ /* Even if the client doesn't want focus, we still need to focus the
+ * container to not break focus workflows. Our handling towards X will
+ * take care of not setting the input focus. However, one exception to
+ * this are clients using the globally active input model which we
+ * don't want to focus at all. */
+ if (nc->window->doesnt_accept_focus && !nc->window->needs_take_focus) {
+ set_focus = false;
+ }
+ }
+