示例#1
0
        protected override void exec()
        {
            if (help_option) return;

            Console.WriteLine ("Sending a synthetic KeyPress...");
            KeyPress key_event = new KeyPress (display);
            key_event.set_window (window);
            key_event.set_detail (display.input.keysym_to_keycode ('t'));
            window.send_event (false, Event.NO_EVENT_MASK, key_event);

            Console.WriteLine ("Sending a synthetic ButtonPress to exit...");
            ButtonPress button_event = new ButtonPress (display);
            key_event.set_window (window);
            window.send_event (false, Event.NO_EVENT_MASK, button_event);

            while (!exit_now) {
              dispatch_event ();
              Console.WriteLine ("Received: " + evt);
            }

            display.close ();
        }
示例#2
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;
            }
        }