示例#1
0
        public void set_focus(Client client, bool warp_pointer)
        {
            /* Process return value from next_client_* () to prevent looping.
             *
             * Case 1 = !focus_key_pressed && client == null. next_client_* fails
             * to find a matching client. Operation aborts and this method simply
             * returns.
             *
             * Case 2 = focus_key_pressed && client == null. next_client_* detects
             * a cycle (start pressing TAB on client A, navigate all matching
             * clients, and come back to client A). Cycling operation restarts and
             * this method continues with client = focus_base.
             *
             * @see #next_client(Client, bool)
             * @see #focus_so_far
             */
            if (!focus_key_pressed && client == null) return;

            if (focus_key_pressed && client == null) {
              client = focus_base;
              focus_so_far.Clear ();
              if (focus_base.class_hint != null)
            focus_so_far.Add (focus_base.class_hint.res_class ());
            }

            client.raise ();		// we choose to do it
            focus = client;

            /* At this point, and only at this point, we are 100% sure that the
             * window is mapped and hence can be assigned focus to. Otherwise, an
             * {@link Error#BAD_WINDOW} will result.
             */
            focus.set_input_focus ();

            // give hint
            if (warp_pointer) client.warp_pointer (10, 10);

            /* For changing focus in focus_key_pressed mode, do not update client order
             * until the user decides which window to stay with and releases focus
             * key modifier.
             *
             * @see #when_key_release(KeyRelease)
             */
            if (!focus_key_pressed) update_client_order (focus);
        }