Example #1
0
        // opcode 74 - poly text8

        /**
         * @see <a href="XDrawText.html">XDrawText</a>
         */
        public void poly_text(GC gc, int x, int y, Text [] texts)
        {
            Request request = new Request(display, 74,
                                          4 + Data.unit(length(texts, 8)));

            request.write4(id);
            request.write4(gc.id);
            request.write2(x);
            request.write2(y);

            for (int i = 0; i < texts.Length; i++)
            {
                if (texts [i].font != null)
                {
                    request.write1(255);               // font-shift indicator
                    request.write4(texts [i].font.id); // java = MSB
                }

                request.write1(texts [i].s.Length);
                request.write1(texts [i].delta);
                request.write1(texts [i].s);
            }

            display.send_request(request);
        }
Example #2
0
        /**
         * @see <a href="XOpenDisplay.html">XOpenDisplay</a>
         */
        public Display(String hostname, int display_no, int screen_no)
        {
            default_screen_no = screen_no;
            connection        = new Connection(this, hostname, display_no);

            // authorization protocol
            String auth_name = "";
            String auth_data = "";
            int    n         = Data.len(auth_name);
            int    d         = Data.len(auth_data);

            Request request = new Request(this, 'B', // java = MSB
                                          3 + Data.unit(auth_name) + Data.unit(auth_data));

            request.index = 2;  // connection setup request hack
            request.write2(11); // major version
            request.write2(0);  // minor version
            request.write2(auth_name.Length);
            request.write2(auth_data.Length);
            request.write1(auth_name);
            request.write1(auth_data);

            init_server_info(read_reply(request));
            init_defaults();
            init_big_request_extension();
        }
Example #3
0
        // opcode 90 - store named color

        /**
         * @see <a href="XStoreNamedColor.html">XStoreNamedColor</a>
         */
        public void store_named_color(int pixel, String name, bool do_reds,
                                      bool do_greens, bool do_blues)
        {
            int do_color = 0;

            if (do_reds)
            {
                do_color |= 0x01;
            }
            if (do_greens)
            {
                do_color |= 0x02;
            }
            if (do_blues)
            {
                do_color |= 0x04;
            }

            Request request = new Request(display, 90, do_color, 4 + Data.unit(name));

            request.write4(id);
            request.write4(pixel);
            request.write2(name.Length);
            request.write1(name);
            display.send_request(request);
        }
Example #4
0
        // opcode 116 - set pointer mapping

        /**
         * @return valid:
         * {@link #SUCCESS},
         * {@link #BUSY}
         *
         * @see <a href="XSetPointerMapping.html">XSetPointerMapping</a>
         */
        public int set_pointer_mapping(byte [] map)
        {
            Request request = new Request(display, 116, map.Length, 2 + Data.unit(map));

            request.write1(map);
            return(display.read_reply(request).read1(1));
        }
Example #5
0
        // opcode 48 - query text extents

        /**
         * @see <a href="XQueryTextExtents.html">XQueryTextExtents</a>
         */
        public TextExtentReply text_extent(String s)
        {
            Request request = new Request(display, 48, s.Length % 2 == 1,
                                          2 + Data.unit(s));

            request.write4(id);
            request.write1(s);
            return(new TextExtentReply(display.read_reply(request)));
        }
Example #6
0
        // opcode 118 - set modifier mapping

        /**
         * @return valid:
         * {@link #SUCCESS},
         * {@link #BUSY},
         * {@link #FAILED}
         *
         * @see <a href="XSetModifierMapping.html">XSetModifierMapping</a>
         */
        public int set_modifier_mapping(int keycodes_per_modifier,
                                        byte [] keycodes)
        {
            Request request = new Request(display, 118, keycodes_per_modifier,
                                          1 + Data.unit(keycodes));

            request.write1(keycodes);
            return(display.read_reply(request).read1(1));
        }
Example #7
0
        // opcode 98 - query extension

        /**
         * @see <a href="XQueryExtension.html">XQueryExtension</a>
         */
        public ExtensionReply extension(String name)
        {
            Request request = new Request(this, 98, 2 + Data.unit(name));

            request.write2(name.Length);
            request.write2_unused();
            request.write1(name);
            return(new ExtensionReply(read_reply(request)));
        }
Example #8
0
        // opcode 51 - set font path

        /**
         * @see <a href="XSetFontPath.html">XSetFontPath</a>
         */
        public void set_font_path(int count, String path)
        {
            Request request = new Request(this, 51, 2 + Data.unit(path));

            request.write2(count);
            request.write2_unused();
            request.write1(path);
            send_request(request);
        }
Example #9
0
        // opcode 58 - set dashes

        /**
         * @see <a href="XSetDashes.html">XSetDashes</a>
         */
        public void set_dashes(int dash_offset, byte [] dashes)
        {
            Request request = new Request(display, 58, 3 + Data.unit(dashes));

            request.write4(id);
            request.write2(dash_offset);
            request.write2(dashes.Length);
            request.write1(dashes);
            display.send_request(request);
        }
Example #10
0
        // opcode 109 - change hosts

        /**
         * @param mode valid:
         * {@link #INSERT},
         * {@link #DELETE}
         *
         * @see <a href="XAddHost.html">XAddHost</a>
         * @see <a href="XRemoveHost.html">XRemoveHost</a>
         */
        public void change_hosts(int mode, int family, byte [] host)
        {
            Request request = new Request(this, 109, mode, 2 + Data.unit(host));

            request.write1(family);
            request.write1_unused();
            request.write2(host.Length);
            request.write1(host);
            send_request(request);
        }
Example #11
0
        // opcode 77 - image text16

        /**
         * @see <a href="XDrawImageString16.html">XDrawImageString16</a>
         */
        public void image_text16(GC gc, int x, int y, String s)
        {
            Request request = new Request(display, 77, s.Length / 2,
                                          4 + Data.unit(s));

            request.write4(id);
            request.write4(gc.id);
            request.write2(x);
            request.write2(y);
            request.write1(s);
            display.send_request(request);
        }
Example #12
0
        // opcode 50 - list fonts with info

        /**
         * @see <a href="XListFontsWithInfo.html">XListFontsWithInfo</a>
         */
        public Data fonts_with_info(String pattern,
                                    int max_name_count)
        {
            Request request = new Request(this, 50, 2 + Data.unit(pattern));

            request.write2(max_name_count);
            request.write2(pattern.Length);
            request.write1(pattern);

            // TODO deal with multiple replies
            return(read_reply(request));
        }
Example #13
0
        public Enum fonts(String pattern, int max_name_count)
        {
            Request request = new Request(this, 49, 2 + Data.unit(pattern));

            request.write2(max_name_count);
            request.write2(pattern.Length);
            request.write1(pattern);

            Data reply = read_reply(request);

            return(new FontsEnum(this, reply, 32, reply.read2(8)));
        }
Example #14
0
        // opcode 45 - open font

        /**
         * @see <a href="XLoadFont.html">XLoadFont</a>
         */
        public Font(Display display, String name)

            : base(display)
        {
            this.name = name;

            Request request = new Request(display, 45, 3 + Data.unit(name));

            request.write4(id);
            request.write2(name.Length);
            request.write2_unused();
            request.write1(name);
            display.send_request(request);
        }
Example #15
0
        // opcode 16 - intern atom

        /**
         * @see <a href="XInternAtom.html">XInternAtom</a>
         */
        public Atom(Display display, String name, bool only_if_exists)
        {
            this.display = display;
            this.name    = name;

            Request request = new Request(display, 16, only_if_exists, 2 + Data.unit(name));

            request.write2(name.Length);
            request.write2_unused();
            request.write1(name);

            Data reply = display.read_reply(request);

            id = reply.read4(8);

            display.atom_ids.Add(id, this);
            display.atom_names.Add(name, this);
        }
Example #16
0
        // opcode 92 - lookup color

        /**
         * @see <a href="XLookupColor.html">XLookupColor</a>
         */
        public Color lookup_color(String name)
        {
            Request request = new Request(display, 92, 3 + Data.unit(name));

            request.write4(id);
            request.write2(name.Length);
            request.write2_unused();
            request.write1(name);

            Data  reply = display.read_reply(request);
            Color color = new Color(0);

            color.name   = name;
            color.exact  = new RGB(reply.read2(8), reply.read2(10), reply.read2(12));
            color.visual = new RGB(reply.read2(14), reply.read2(16),
                                   reply.read2(18));
            return(color);
        }
Example #17
0
  // opcode 18 - change property
  /**
   * Extra parameters (offset and data_format) are used to support Data
   * class as parameter for writing. See set_wm_normal_hints ().
   *
   * @param mode valid:
   * {@link #REPLACE},
   * {@link #PREPEND},
   * {@link #APPEND}
   * 
   * @param format: valid:
   * <code>8</code>,
   * <code>16</code>,
   * <code>32</code>
   *
   * @param data_format: valid:
   * <code>8</code>,
   * <code>16</code>,
   * <code>32</code>
   * 
   * @see <a href="XChangeProperty.html">XChangeProperty</a>
   */ 
  public void change_property (int mode, int n, Atom property, Atom type,
    int format, Object data, int offset, int data_format) {

    Request request = new Request (display, 18, mode, 6+Data.unit (n*format/8));
    request.write4 (id);
    request.write4 (property.id);
    request.write4 (type.id);
    request.write1 (format);
    request.write3_unused ();
    request.write4 (n);		// data length in format unit

    // data
    switch (data_format) {
    case 8: request.write1 ((byte []) data, offset); break;    
    case 16: request.write2 ((int []) data, offset); break;
    case 32: request.write4 ((int []) data, offset); break;
    }
    display.send_request (request);
  }
Example #18
0
        // opcode 72 - put image
        public void put_small_image(GC gc, Image image, int y1, int y2,
                                    int x, int y)
        {
            int offset = image.line_byte_count * y1;
            int length = image.line_byte_count * (y2 - y1);

            Request request = new Request(display, 72, image.format,
                                          6 + Data.unit(length));

            request.write4(id);
            request.write4(gc.id);
            request.write2(image.width);
            request.write2(y2 - y1);
            request.write2(x);
            request.write2(y);
            request.write1(image.left_pad);
            request.write1(image.pixmap_format.depth());
            request.write2_unused();
            request.write1(image.data, offset, length);
            display.send_request(request);
        }
Example #19
0
        // opcode 75 - poly text16

        /**
         * @see <a href="XDrawText16.html">XDrawText16</a>
         */
        public void poly_text16(GC gc, int x, int y, Text [] texts)
        {
            Request request = new Request(display, 75,
                                          4 + Data.unit(length(texts, 16)));

            request.write4(id);
            request.write4(gc.id);
            request.write2(x);
            request.write2(y);


            for (int i = 0; i < texts.Length; i++)
            {
                if (texts [i].font != null)
                {
                    request.write1(255);               // font-shift indicator
                    request.write4(texts [i].font.id); // java = MSB
                }

                String s = texts [i].s;

                if (s[0] > 128) // non-ascii
                {
                    request.write1(s.Length / 2);
                    request.write1(texts [i].delta);
                    request.write1(s);
                }
                else    // ascii
                {
                    request.write1(s.Length);
                    request.write1(texts [i].delta);
                    request.write2(s);
                }
            }

            display.send_request(request);
        }