Exemple #1
0
        // opcode 97 - query best size

        /**
         * @param klass valid:
         * {@link #CURSOR},
         * {@link #TILE},
         * {@link #STIPPLE}
         *
         * @see <a href="XQueryBestSize.html">XQueryBestSize</a>
         */
        public Size best_size(int klass, int width, int height)
        {
            Request request = new Request(display, 97, 3);

            request.write4(id);
            request.write2(width);
            request.write2(height);

            Data reply = display.read_reply(request);

            return(new Size(reply.read2(8), reply.read2(10)));
        }
Exemple #2
0
        public void init_server_info(Data reply)
        {
            connected     = true;
            release_no    = reply.read4(8);
            resource_base = reply.read4(12);
            resource_mask = reply.read4(16);
            int vendor_length = reply.read2(24);

            extended_maximum_request_length
                = maximum_request_length = reply.read2(26);
            int screen_count        = reply.read1(28);
            int pixmap_format_count = reply.read1(29);

            image_byte_order            = reply.read1(30);
            bitmap_format_bit_order     = reply.read1(31);
            bitmap_format_scanline_unit = reply.read1(32);
            bitmap_format_scanline_pad  = reply.read1(33);

            int min_keycode = reply.read1(34);
            int max_keycode = reply.read1(35);

            input = new Input(this, min_keycode, max_keycode);
            input.keyboard_mapping();

            vendor = reply.read_string(40, vendor_length);

            // pixmap formats
            pixmap_formats = new Pixmap.Format [pixmap_format_count];
            int pixmap_formats_offset = 40 + Data.len(vendor_length);

            for (int i = 0; i < pixmap_format_count; i++)
            {
                pixmap_formats [i] = new Pixmap.Format(
                    reply, pixmap_formats_offset + i * 8);
            }

            // screens

            if (default_screen_no < 0 || default_screen_no >= screen_count)
            {
                throw new Exception("Invalid screen number (screen-count "
                                    + screen_count + "): " + default_screen_no);
            }

            screens = new Screen [screen_count];
            int screen_offset = pixmap_formats_offset + 8 * pixmap_format_count;

            for (int i = 0; i < screen_count; i++)
            {
                screens [i]    = new Screen(this, reply, screen_offset);
                screen_offset += screens [i].Length;
            }
        }
Exemple #3
0
        // opcode 84 - alloc color

        /**
         * @see <a href="XAllocColor.html">XAllocColor</a>
         */
        public Color alloc_color(int red, int green, int blue)
        {
            Request request = new Request(display, 84, 4);

            request.write4(id);
            request.write2(red);
            request.write2(green);
            request.write2(blue);

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

            color.exact = new RGB(reply.read2(8), reply.read2(10), reply.read2(12));
            return(color);
        }
Exemple #4
0
  public Enum properties () {
    Request request = new Request (display, 21, 2);
    request.write4 (id);

    Data reply = display.read_reply (request);
    return new PropertiesEnum (display, reply, 32, reply.read2 (8));
  }
Exemple #5
0
  public Enum installed_colormaps () {
    Request request = new Request (display, 83, 2);
    request.write4 (id);

    Data reply = display.read_reply (request);
    return new InstalledColormapsEnum (this, reply, 32, reply.read2 (8));
  }
Exemple #6
0
        // opcode 52 - get font path

        /**
         * @return valid: {@link Enum#next_string()}
         * @see <a href="XGetFontPath.html">XGetFontPath</a>
         */
        public Enum font_path()
        {
            Request request = new Request(this, 52, 1);

            Data reply = read_reply(request);

            return(new Enum(reply, 32, reply.read2(8)));
        }
Exemple #7
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)));
        }
Exemple #8
0
        public Enum colors(int [] pixels)
        {
            Request request = new Request(display, 91, 2 + pixels.Length);

            request.write4(id);

            for (int i = 0; i < pixels.Length; i++)
            {
                request.write4(pixels [i]);
            }

            Data reply = display.read_reply(request);

            return(new ColormapEnum(reply, 32, reply.read2(8)));
        }
Exemple #9
0
        // opcode 17 - get atom name

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

            Request request = new Request(display, 17, 2);

            request.write4(id);

            Data    reply = display.read_reply(request);
            int     len   = reply.read2(8);
            Decoder dec   = Encoding.ASCII.GetDecoder();

            char [] d = new char[len];
            len  = dec.GetChars(reply.data, 32, len, d, 0);
            name = new String(d, 0, len);

            display.atom_ids.Add(id, this);
            display.atom_names.Add(name, this);
        }
Exemple #10
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);
        }
Exemple #11
0
        public void init_server_info(Data reply)
        {
            connected = true;
            release_no = reply.read4 (8);
            resource_base = reply.read4 (12);
            resource_mask = reply.read4 (16);
            int vendor_length = reply.read2 (24);
            extended_maximum_request_length
              = maximum_request_length = reply.read2 (26);
            int screen_count = reply.read1 (28);
            int pixmap_format_count = reply.read1 (29);

            image_byte_order = reply.read1 (30);
            bitmap_format_bit_order = reply.read1 (31);
            bitmap_format_scanline_unit = reply.read1 (32);
            bitmap_format_scanline_pad = reply.read1 (33);

            int min_keycode = reply.read1 (34);
            int max_keycode = reply.read1 (35);
            input = new Input (this, min_keycode, max_keycode);
            input.keyboard_mapping ();

            vendor = reply.read_string (40, vendor_length);

            // pixmap formats
            pixmap_formats = new Pixmap.Format [pixmap_format_count];
            int pixmap_formats_offset = 40 + Data.len (vendor_length);
            for (int i=0; i<pixmap_format_count; i++)
              pixmap_formats [i] = new Pixmap.Format (
            reply, pixmap_formats_offset + i*8);

            // screens

            if (default_screen_no < 0 || default_screen_no >= screen_count)
              throw new Exception ("Invalid screen number (screen-count "
            + screen_count + "): " + default_screen_no);

            screens = new Screen [screen_count];
            int screen_offset = pixmap_formats_offset + 8*pixmap_format_count;
            for (int i=0; i<screen_count; i++) {
              screens [i] = new Screen (this, reply, screen_offset);
              screen_offset += screens [i].Length;
            }
        }