Example #1
0
        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;
            }
        }