Ejemplo n.º 1
0
 // xtest opcode 1 - compare cursor
 /**
    * @param cursor possible:
    * {@link Cursor#NONE},
    * {@link Cursor#CURRENT}
    *
    * @see <a href="XTestCompareCursorWithWindow.html">
    * XTestCompareCursorWithWindow</a>
    */
 public bool compare_cursor(Window window, Cursor cursor)
 {
     Request request = new Request (display, major_opcode, 1, 3);
     request.write4 (window.id);
     request.write4 (cursor.id);
     return display.read_reply (request).read_bool (1);
 }
Ejemplo n.º 2
0
 // opcode 78 - create colormap
 /**
    * @param alloc valid:
    * {@link #NONE},
    * {@link #ALL}
    *
    * @see <a href="XCreateColormap.html">XCreateColormap</a>
    */
 public Colormap(Window window, int visual_id, bool alloc_all)
     : base(window.display)
 {
     Request request = new Request (display, 78, alloc_all, 4);
     request.write4 (id);
     request.write4 (window.id);
     request.write4 (visual_id);
     display.send_request (request);
 }
Ejemplo n.º 3
0
        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 ();
        }
Ejemplo n.º 4
0
        public void send_key(Window window, int keysym)
        {
            bool capital = keysym >= 'A' && keysym <= 'Z';
            // keysym of corresponding small letter
            int small_keysym = !capital ? keysym : keysym + ('a' - 'A');

            KeyPress key_event = new KeyPress (display);
            key_event.set_window (window);
            key_event.set_detail (display.input.keysym_to_keycode (small_keysym));
            if (capital) key_event.set_state (gnu.x11.Input.SHIFT_MASK);

            window.send_event (false, Event.NO_EVENT_MASK, key_event);
        }
Ejemplo n.º 5
0
        public Graphics(String [] args, int width, int height)
            : base(args)
        {
            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 = new Window (display.default_root, 10, 10,
              width, height, 5, win_attr);

            window.set_wm (this, "main");
            window.set_wm_delete_window ();
        }
Ejemplo n.º 6
0
        //throws gnu.x11.extension.NotFoundException {
        public PrintHello(String [] args)
            : base(args)
        {
            String printer_name = option.option ("printer");

            about ("0.1", "print hello world",
              "Stephen Tse <*****@*****.**>",
              "http://escher.sourceforge.net/");

            if (help_option) return;

            Print print = new Print (display);
            Print.Context context = print.create_context (printer_name);

            Console.WriteLine (print);
            Console.WriteLine (context);

            context.set_attributes (Print.Context.JOB_ATTRIBUTE_POOL,
              Print.Context.ATTRIBUTE_MERGE,
              "*job-name: Hello world for Xprint");
            context.set ();
            print.start_job (Print.SPOOL);

            Window root = context.screen ();
            GC gc = root.screen ().default_gc ();
            gc.set_font (new gnu.x11.Font (display, FONT));
            Window window = new Window (root, 100, 100, 100, 100);
            window.create ();

            print.start_page (window);
            window.map ();
            window.text (gc, 20, 30, "Hello World!");
            print.end_page ();

            print.end_job ();
            context.destroy ();
            display.close ();
        }
Ejemplo n.º 7
0
     // xtest opcode 2 - fake input
     /**
        * @param type valid:
        * {@link #KEY_PRESS},
        * {@link #KEY_RELEASE},
        * {@link #BUTTON_PRESS},
        * {@link #BUTTON_RELEASE},
        * {@link #MOTION_NOTIFY}
        *
        * @param time possible: {@link gnu.x11.Display#CURRENT_TIME}
        */
     public void fake_input(int type, int detail, int delay, Window root, 
 int x, int y)
     {
         Request request = new Request (display, major_opcode, 2, 9);
         request.write1 (type);
         request.write1 (detail);
         request.write2_unused ();
         request.write4 (delay);
         request.write4 (root.id);
         request.write_unused (8);
         request.write2 (x);
         request.write2 (y);
         display.send_request (request);
     }
Ejemplo n.º 8
0
 /**
    * @see #Window(Window, int, int, int, int)
    */
 public Window(Window parent, Rectangle geometry)
     : this(parent, geometry.x, geometry.y, geometry.width, geometry.height)
 {
 }
Ejemplo n.º 9
0
 // opcode 7 - reparent window
 /**
    * @see <a href="XReparentWindow.html">XReparentWindow</a>
    */
 public void reparent(Window parent, int x, int y)
 {
     Request request = new Request (display, 7, 4);
     request.write4 (id);
     request.write4 (parent.id);
     request.write2 (x);
     request.write2 (y);
     display.send_request (request);
 }
Ejemplo n.º 10
0
     // opcode 26 - grab pointer
     /**
        * @param pointer_mode valid:
        * {@link #SYNCHRONOUS},
        * {@link #ASYNCHRONOUS}
        *
        * @param keyboard_mode valid:
        * {@link #SYNCHRONOUS},
        * {@link #ASYNCHRONOUS}
        *
        * @param confine_to possible: {@link #NONE}
        * @param cursor possible: {@link Cursor#NONE}
        * @param time possible: {@link Display#CURRENT_TIME}
        *
        * @return valid:
        * {@link #SUCCESS},
        * {@link #ALREADY_GRABBED},
        * {@link #FROZEN},
        * {@link #INVALID_TIME},
        * {@link #NOT_VIEWABLE}
        *
        * @see <a href="XGrabPointer.html">XGrabPointer</a>
        */
     public int grab_pointer(bool owner_events, int event_mask, 
 int pointer_mode, int keyboard_mode, Window confine_to, Cursor cursor,
 int time)
     {
         Request request = new Request (display, 26, owner_events, 6);
         request.write4 (id);
         request.write2 (event_mask);
         request.write1 (pointer_mode);
         request.write1 (keyboard_mode);
         request.write4 (confine_to.id);
         request.write4 (cursor.id);
         request.write4 (time);
         return display.read_reply (request).read1 (1);
     }
Ejemplo n.º 11
0
 // print 13 - start page
 /**
    * @see <a href="XpStartPage.html">XpStartPage</a>
    */
 public void start_page(Window window)
 {
     Request request = new Request (display, major_opcode, 13, 2);
     request.write4 (window.id);
     display.send_request (request);
 }
Ejemplo n.º 12
0
 public void set_root(Window w)
 {
     set_root_id (w.id);
 }
Ejemplo n.º 13
0
 public static Object intern(Window window)
 {
     return intern (window.display, window.id);
 }
Ejemplo n.º 14
0
     // opcode 41 - warp pointer
     /**
        * @param src possible: {@link #NONE}
        * @see <a href="XWarpPointer.html">XWarpPointer</a>
        */
     public void warp_pointer(Window src, int src_x, int src_y, 
 int src_width, int src_height, int dest_x, int dest_y)
     {
         Request request = new Request (display, 41, 6);
         request.write4 (src.id);
         request.write4 (id);
         request.write2 (src_x);
         request.write2 (src_y);
         request.write2 (src_width);
         request.write2 (src_height);
         request.write2 (dest_x);
         request.write2 (dest_y);
         display.send_request (request);
     }
Ejemplo n.º 15
0
     /**
        * @see <a href="XTestFakeMotionEvent.html">XTestFakeMotionEvent</a>
        */
     public void fake_motion_event(Window root, int x, int y, 
 bool relative, int delay)
     {
         fake_input (MOTION_NOTIFY, relative ? 1 : 0, delay, root, x, y);
     }
Ejemplo n.º 16
0
 /**
    * Initialize member fields only without creating object in X server.
    */
 public Window(Window parent, int x, int y, int width, int height)
     : base(parent.display)
 {
     this.parent = parent;
     this.x = x;
     this.y = y;
     this.width = width;
     this.height = height;
 }
Ejemplo n.º 17
0
     // opcode 40 - translate coordinates
     /**
        * @see <a href="XTranslateCoordinates.html">XTranslateCoordinates</a>
        */
     public CoordinateReply translate_coordinates(Window src, 
 int src_x, int src_y)
     {
         Request request = new Request (display, 40, 4);
         request.write4 (src.id);
         request.write4 (id);
         request.write2 (src_x);
         request.write2 (src_y);
         return new CoordinateReply (display.read_reply (request));
     }
Ejemplo n.º 18
0
        /**
           * @see #change_property(int, int, Atom, Atom, int, Object, int, int)
           */
        public void set_wm_state(int state, Window icon)
        {
            Atom wm_state = (Atom) Atom.intern (display, "WM_STATE");
            int [] data = {state, icon.id};

            change_property (REPLACE, 2, wm_state, wm_state, 32, data, 0, 32);
        }
Ejemplo n.º 19
0
     /**
        * @see #Window(Window, int, int, int, int, int, Window.Attributes)
        */
     public Window(Window parent, Rectangle geometry, int border_width,
 Attributes attr)
         : this(parent, geometry.x, geometry.y, geometry.width, geometry.height,
   border_width, attr)
     {
     }
Ejemplo n.º 20
0
 public virtual void set_window(Window window)
 {
     set_window (window.id);
 }
Ejemplo n.º 21
0
     /**
        * @see #create(int, int, int, int, Window.Attributes)
        */
     public Window(Window parent, int x, int y, int width, int height, 
 int border_width, Attributes attr)
         : this(parent, x, y, width, height)
     {
         create (border_width, attr);
     }
Ejemplo n.º 22
0
 //-- writing
 public void set_event(Window w)
 {
     write4 (4, w.id);
 }
Ejemplo n.º 23
0
        public DisplayHack(String [] args, bool clear, bool erase,
    bool rainbow_color, int default_color_count, int default_delay)
            : base(args)
        {
            this.thread = new Thread (new ThreadStart(this.run));
            this.clear = clear;
            this.erase_ = erase;

            int color_count = option.intt ("color-count",
              "total number of random colors", default_color_count);
            delay = option.longg ("delay",
              "delay between screens in ms", default_delay);

            if (erase) {
              eraser_delay = option.longg ("eraser-delay",
            "delay between iterations of eraser in ms", 10);
              eraser_delta = option.intt ("eraser-delta",
            "granularity of eraser", 5, 1, 10);
              eraser_mode = option.Enum ("eraser-mode",
            "which eraser", Eraser.ALL_STRINGS,
            Eraser.RANDOM_ERASER_INDEX);
            }

            Rectangle geometry = option.rectangle ("geometry",
              "initial geometry of main window",
              new Rectangle (10, 10, 600, 480));

            if (help_option) return;

            gc = gnu.x11.GC.build (display);
            if (erase_) eraser_gc = gnu.x11.GC.build (display);

            colors = new Color [color_count];

            if (rainbow_color)
              for (int i=0; i<color_count; i++)
            colors [i] = display.default_colormap.
              alloc_random_rainbow_color (random);

            else
              for (int i=0; i<color_count; i++)
            colors [i] = display.default_colormap. alloc_random_color (random);

            Window.Attributes win_attr = new Window.Attributes ();
            win_attr.set_background (display.default_black);
            win_attr.set_event_mask (Event.BUTTON_PRESS_MASK
              | Event.STRUCTURE_NOTIFY_MASK
              | Event.EXPOSURE_MASK | Event.KEY_PRESS_MASK);
            window = new Window (display.default_root, geometry, 0, win_attr);

            window.set_wm (this, "main");
            window.set_wm_delete_window ();
        }
Ejemplo n.º 24
0
 public void sibling(Window window)
 {
     sibling_id (window.id);
 }
Ejemplo n.º 25
0
 public override void set_window(Window w)
 {
     write4 (8, w.id);
 }
Ejemplo n.º 26
0
 public InstalledColormapsEnum(Window owner, Data reply, int len, int c)
     : base(reply,len,c)
 {
     this.owner=owner;
 }
Ejemplo n.º 27
0
        public void init_defaults()
        {
            default_screen = screens [default_screen_no];
            default_root = default_screen.root (); // before init default_gc
            default_depth = default_screen.root_depth ();
            default_colormap = default_screen.default_colormap ();
            default_gc = default_screen.default_gc ();
            default_black = new Color (default_screen.black_pixel ());
            default_white = new Color (default_screen.white_pixel ());

            for (int i=pixmap_formats.Length-1; i>=0; i--)
              if (pixmap_formats [i].depth () == default_depth) {
            default_pixmap_format = pixmap_formats [i];
            break;
              }
        }
Ejemplo n.º 28
0
     // opcode 28 - grab button
     /**
        * @param button possible: {@link #ANY_BUTTON}
        * @param modifiers possible: {@link #ANY_MODIFIER}
        * @param pointer_mode valid:
        * {@link #SYNCHRONOUS},
        * {@link #ASYNCHRONOUS}
        *
        * @param keyboard_mode valid:
        * {@link #SYNCHRONOUS},
        * {@link #ASYNCHRONOUS}
        *
        * @param confine_to possible: {@link #NONE}
        * @param cursor possible: {@link Cursor#NONE}
        * @see <a href="XGrabButton.html">XGrabButton</a>
        */
     public void grab_button(int button, int modifiers, bool owner_events,
 int event_mask, int pointer_mode, int keyboard_mode, Window confine_to,
 Cursor cursor)
     {
         Request request = new Request (display, 28, owner_events, 6);
         request.write4 (id);
         request.write2 (event_mask);
         request.write1 (pointer_mode);
         request.write1 (keyboard_mode);
         request.write4 (confine_to.id);
         request.write4 (cursor.id);
         request.write1 (button);
         request.write1_unused ();
         request.write2 (modifiers);
         display.send_request (request);
     }
Ejemplo n.º 29
0
 public void set_child(Window w)
 {
     set_child_id (w.id);
 }
Ejemplo n.º 30
0
     /**
        * Grab button ignoring caps lock (LOCK), num lock (MOD2), and scroll
        * lock (MOD5).
        *
        * @see #grab_button(int, int, bool, int, int, int, Window, Cursor)
        */
     public void grab_button_ignore_locks(int button, int modifiers, 
 bool owner_events, int event_mask, int pointer_mode, 
 int keyboard_mode, Window confine_to, Cursor cursor)
     {
         // Are there a portable way to do this?
         // Sawfish and Icewm use the same technique as well.
         // TODO highly inefficient (many X requests)
         for (int i=0; i<Input.LOCK_COMBINATIONS.Length; i++)
           grab_button (button, modifiers | Input.LOCK_COMBINATIONS [i],
         owner_events, event_mask, pointer_mode, keyboard_mode, confine_to,
         cursor);
     }