private void dispatch_key_press() { KeyPress e = (KeyPress)evt; int keycode = e.detail(); int keystate = e.state(); int keysym = display.input.keycode_to_keysym(keycode, keystate); if ((event_mask & KEYBOARD_BIT) != 0) { handle_keyboard(keysym, keystate, e.event_x(), e.event_y()); } if (keysym == gnu.x11.keysym.Misc.ESCAPE) { exit(); } }
protected override void dispatch_event() { Console.WriteLine("blocking-read event"); evt = display.next_event(); Console.WriteLine("got event " + evt); switch (evt.code()) { case gnu.x11.xevent.ButtonPress.CODE: exit(); break; case ClientMessage.CODE: if (((ClientMessage)evt).delete_window()) { exit(); } break; case Expose.CODE: if (!thread.IsAlive) { thread.Start(); } break; case KeyPress.CODE: { KeyPress e = (KeyPress)evt; int keycode = e.detail(); int keystate = e.state(); int keysym = display.input.keycode_to_keysym(keycode, keystate); if (keysym == 'q' || keysym == 'Q' || keysym == gnu.x11.keysym.Misc.ESCAPE) { exit(); } break; } } }
protected virtual void dispatch_event() { evt = display.next_event(); switch (evt.code()) { case gnu.x11.xevent.ButtonPress.CODE: exit(); break; case ClientMessage.CODE: if (((ClientMessage)evt).delete_window()) { exit(); } break; case Expose.CODE: if (((Expose)evt).count() == 0) { paint(); } break; case KeyPress.CODE: { KeyPress e = (KeyPress)evt; int keycode = e.detail(); int keystate = e.state(); int keysym = display.input.keycode_to_keysym(keycode, keystate); if (keysym == 'q' || keysym == 'Q' || keysym == gnu.x11.keysym.Misc.ESCAPE) { exit(); } break; } } }
public void dispatch_event() { Event evt = display.next_event(); switch (evt.code()) { case ButtonPress.CODE: { int button = ((ButtonPress)evt).detail(); if (button == gnu.x11.Input.BUTTON1) { restart(); } else if (button == gnu.x11.Input.BUTTON3) { exit(); } break; } case ConfigureNotify.CODE: window.set_geometry_cache(((ConfigureNotify)evt).rectangle()); break; case Expose.CODE: if (thread.IsAlive) { restart(); } else { if (clear) { window.clear(false); // before thread starts } thread.Start(); } break; case KeyPress.CODE: { KeyPress e = (KeyPress)evt; int keycode = e.detail(); int keystate = e.state(); int keysym = display.input.keycode_to_keysym(keycode, keystate); if (keysym == ' ') { restart(); } else if (keysym == 'q' || keysym == 'Q' || keysym == gnu.x11.keysym.Misc.ESCAPE) { exit(); } break; } case ClientMessage.CODE: if (((ClientMessage)evt).delete_window()) { exit(); } break; } }
public Hello(String [] args) : base(args) { about("0.1", "hello world", "Stephen Tse <*****@*****.**>", "http://escher.sourceforge.net/", "\nTo quit, press 'q', 'Q', ESCAPE, or any button."); if (help_option) { return; } Window.Attributes win_attr = new Window.Attributes(); win_attr.set_background(display.default_white); win_attr.set_border(display.default_black); win_attr.set_event_mask(Event.BUTTON_PRESS_MASK | Event.EXPOSURE_MASK | Event.KEY_PRESS_MASK); Window window = new Window(display.default_root, 10, 10, 100, 50, 5, win_attr); window.set_wm(this, "main"); window.set_wm_delete_window(); window.map(); while (!exit_now) { Event evt = display.next_event(); switch (evt.code()) { case gnu.x11.xevent.ButtonPress.CODE: exit(); break; case ClientMessage.CODE: if (((ClientMessage)evt).delete_window()) { exit(); } break; case Expose.CODE: if (((Expose)evt).count() == 0) { window.text(display.default_gc, 20, 30, "Hello World!"); } break; case KeyPress.CODE: { KeyPress e = (KeyPress)evt; int keycode = e.detail(); int keystate = e.state(); int keysym = display.input.keycode_to_keysym(keycode, keystate); if (keysym == 'q' || keysym == 'Q' || keysym == gnu.x11.keysym.Misc.ESCAPE) { exit(); } break; } } } display.close(); }