public void when_button_press(ButtonPress evt) { /* Because we are doing grabbing on root window, we should not check * <code>event.window()</code> since it always Equals to * {@link #root}. Instead, check <code>event.child()</code>. */ bool control_down = (evt.state () & gnu.x11.Input.CONTROL_MASK) != 0; bool meta_down = (evt.state () & gnu.x11.Input.META_MASK) != 0; bool on_root = evt.child_id () == 0; if (meta_down && on_root) { // `lanuch-on-root' Process.Start (pref.launch_on_root ()); return; } if (!meta_down && on_root) { // `pointer-root-focus' root.set_input_focus (); return; } Client client = (Client) Client.intern (display, evt.child_id ()); if (client.early_unmapped || client.early_destroyed) return; if (!control_down) return; int button = evt.detail (); switch (button) { case gnu.x11.Input.BUTTON1: if (meta_down) // `delete-window' client.delete (); else { // `focus-with-raise' // same as set_focus () client.raise (); focus = client; focus.set_input_focus (); update_client_order (focus); } break; case gnu.x11.Input.BUTTON2: // `focus-without-raise' focus = client; focus.set_input_focus (); update_client_order (focus); break; case gnu.x11.Input.BUTTON3: if (meta_down) client.kill (); // `kill-window' else { // `lower-behind' // give focus to some other window (under pointer) client.lower (); focus = (Client) Client.intern (root.pointer ().child ()); focus.set_input_focus (); update_client_order (focus); // != client } break; } }
//throws NotFoundException public Puppet(String [] args) : base(args) { Preference.staticInit(); print_event = option.booleann ("print-event", "dump all events for debug", false); space = option.rectangle ("space", "workspace for normal windows", pref.space ()); about ("0.1", "puppet window manager", "Stephen Tse <*****@*****.**>", "http://escher.sourceforge.net/", "\nFor bindings, check http://escher.sourceforge.net/" + "current/doc/gnu/app/puppet/Puppet.html."); if (help_option) return; /** * addShutdownHook in IBM JDK 1.3 does not seem to work for processing * Control-C. It simply ignores TERM signal instead of calling shutdown * hooks and then exiting. */ // Runtime.getRuntime ().addShutdownHook (new Thread () { // public void run () { System.err.println ("shutting down..."); }}); root = display.default_root; Window.NONE.display = display; // for move pointer xtest = new XTest (display); // for press button registers = new Client [display.input.max_keycode - display.input.min_keycode]; _mit_priority_colors = (Atom) Atom.intern (display, "_MIT_PRIORITY_COLORS"); wm_change_state = (Atom) Atom.intern (display, "WM_CHANGE_STATE"); wm_state = (Atom) Atom.intern (display, "WM_STATE"); wm_colormap_windows = (Atom) Atom.intern (display, "WM_COLORMAP_WINDOWS"); wm_protocols = (Atom) Atom.intern (display, "WM_PROTOCOLS"); wm_take_focus = (Atom) Atom.intern (display, "WM_TAKE_FOCUS"); wm_save_yourself = (Atom) Atom.intern (display, "WM_SAVE_YOURSELF"); wm_delete_window = (Atom) Atom.intern (display, "WM_DELETE_WINDOW"); sm_client_id = (Atom) Atom.intern (display, "SM_CLIENT_ID"); wm_client_leader = (Atom) Atom.intern (display, "WM_CLIENT_LEADER"); wm_window_role = (Atom) Atom.intern (display, "WM_WINDOW_ROLE"); control_root_window (); scan_children (); focus = (Client) Client.intern (root.pointer ().child ()); focus.set_input_focus (); grab_keybut (); Console.WriteLine ("Initialization completed."); while (!exit_now) read_and_dispatch_event (); }
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); }