Beispiel #1
0
     public Error build(Display display, Data data, int code,
 int seq_no, int bad, int minor_opcode, int major_opcode)
     {
         String error_string = ERROR_STRINGS [code - first_error];
         return new Error (display, error_string, code, seq_no, bad,
           minor_opcode, major_opcode);
     }
Beispiel #2
0
        public Enum(Data data, int offset, int count)
            : base(data, offset)
        {
            this.count = count;

            // save these for later reset
            start_offset = this.offset;
            start_count = count;
        }
Beispiel #3
0
 public KeyboardControlReply(Data data)
     : base(data)
 {
 }
Beispiel #4
0
        //throws IOException
        public static Data build_reply(Display display)
        {
            // 8 = fixed length of basic connection reply
            // 32 = fixed length of basic other reply
            int basic = display.connected ? 32 : 8;

            byte [] b = new byte [8];
            b [0] = 1;			// reply code

            display.connection.din.Read (b, 1, 7); // reply length

            int extra = 4 * (display.connected
              ? ((b [4] & 0xff) << 24) // general reply
              | ((b [5] & 0xff) << 16)
              | ((b [6] & 0xff) << 8)
              | (b [7] & 0xff)
              : ((b [6] & 0xff) << 8) | (b [7] & 0xff)); // connection reply

            Data reply = new Data ();
            reply.data = new byte [basic + extra];
            System.Array.Copy (b, 0, reply.data, 0, 8);
            display.connection.din.Read (
              reply.data, 8, basic - 8 + extra);

            return reply;
        }
Beispiel #5
0
 public Screen(Display display, Data data, int offset)
     : base(data, offset)
 {
     this.display = display;
 }
Beispiel #6
0
 public ScreenSaverReply(Data data)
     : base(data)
 {
 }
Beispiel #7
0
 public ExtensionReply(Data data)
     : base(data)
 {
 }
Beispiel #8
0
 public Depth(Data data, int offset)
     : base(data, offset)
 {
 }
Beispiel #9
0
 public TextExtentReply(Data data)
     : base(data)
 {
 }
Beispiel #10
0
 public Visual(Data data, int offset)
     : base(data, offset)
 {
 }
Beispiel #11
0
 public XIDRangeReply(Data data)
     : base(data)
 {
 }
Beispiel #12
0
 public Direct(Data data, int offset)
     : base(data, offset)
 {
 }
Beispiel #13
0
 public Format(Data data, int offset)
     : base(data, offset)
 {
 }
Beispiel #14
0
 public PropertiesEnum(Display display, Data owner, int len, int c)
     : base(owner,len,c)
 {
     this.display=display;
 }
Beispiel #15
0
 public InstalledColormapsEnum(Window owner, Data reply, int len, int c)
     : base(reply,len,c)
 {
     this.owner=owner;
 }
Beispiel #16
0
 public void write1(int j, Data d)
 {
     write1 (j, d.data, d.offset, d.n ());
 }
Beispiel #17
0
 public void write1(Data d)
 {
     write1 (d.data, d.offset, d.n ());
 }
Beispiel #18
0
 public FontReply(Data data)
     : base(data)
 {
 }
Beispiel #19
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;
            }
        }
Beispiel #20
0
        private void init_image()
        {
            int band = IMAGE_SIZE/4;

            IMAGE0 = new byte [IMAGE_SIZE] [] [];
            for (int i=0; i<band; i++) {
            IMAGE0[i] = new byte[IMAGE_SIZE][];
              for (int j=0; j<IMAGE_SIZE; j++) {
            IMAGE0[i][j] = new byte[4];

            IMAGE0 [i + 0*band] [j] [0] = (byte) 0xff;
            IMAGE0 [i + 0*band] [j] [1] = (byte) 0x00;
            IMAGE0 [i + 0*band] [j] [2] = (byte) 0x00;
            IMAGE0 [i + 0*band] [j] [3] = (byte) 0xff;

            IMAGE0 [i + 1*band] [j] [0] = (byte) 0xff;
            IMAGE0 [i + 1*band] [j] [1] = (byte) 0x00;
            IMAGE0 [i + 1*band] [j] [2] = (byte) 0xff;
            IMAGE0 [i + 1*band] [j] [3] = (byte) 0x00;

            IMAGE0 [i + 2*band] [j] [0] = (byte) 0xff;
            IMAGE0 [i + 2*band] [j] [1] = (byte) 0xff;
            IMAGE0 [i + 2*band] [j] [2] = (byte) 0x00;
            IMAGE0 [i + 2*band] [j] [3] = (byte) 0x00;

            IMAGE0 [i + 3*band] [j] [0] = (byte) 0x00;
            IMAGE0 [i + 3*band] [j] [1] = (byte) 0xff;
            IMAGE0 [i + 3*band] [j] [2] = (byte) 0x00;
            IMAGE0 [i + 3*band] [j] [3] = (byte) 0xff;
              }
            }
            IMAGE = new Data (IMAGE0);
        }
Beispiel #21
0
 public HostsReply(Data data)
     : base(data)
 {
 }
Beispiel #22
0
        public Event read_event(bool blocking, bool remove)
        {
            if (events.Count > 0)
              lock (events) {
            Event evt = (Event) events[0];
            events.Remove (0);
            return evt;
              }

            Data message = null;
            while (message == null) {
              /* ALWAYS yield, despite priorities of threads, to the thread running
               * `read_reply(Request)' to avoid dead-lock.
               *
               * Note that yielding once does not guarantee the thread running
               * `read_reply(Request)' will gain the control even when they have a
               * higher priority than this thread. We must repeatively yield until
               * it does so. The number of yields is unbounded.
               *
               * Reference: http://www.eng.uiowa.edu/~skaliann/books/jthreads/index.htm.
               */
              while (reading_reply) Thread.SpinWait (100);

              lock (read_lock) {
            message = read_message (blocking);
            if (message.read1 (0) == 1) { // reply
              saved_reply = message;
              message = null;
            }
              }
            }

            if (!remove) events.Add (message);
            return (Event) message;
        }
Beispiel #23
0
 public FontsEnum(Display owner, Data data, int len, int c)
     : base(data,len,c)
 {
     this.owner=owner;
 }
Beispiel #24
0
        public Data read_reply(Request request)
        {
            reading_reply = true;       // outside lock block

            /* Synchronize so that `send(Request, bool)' and
             * `read_message(bool)' behave atomically. That is, a reply is
             * matched with its corresponding request.
             *
             * Note the input stream `din' is already used to lock for atomic
             * reading in `read_message(bool)'.
             */
            lock (output) {
              int seq_no = send (request, true);

              Data message;
              lock (read_lock) {
            reading_reply = false;
            if (saved_reply != null) {
              message = saved_reply;
              saved_reply = null;

            } else {
              while ((message = read_message (true)) is Event)
            events.Add (message);
            }
              }

              int reply_seq_no = message.read2 (2);
              if (display.connected && reply_seq_no != seq_no)
            throw new Error (
              "X server error: reply out of order: expect "
              + seq_no + " got " + reply_seq_no);
              return message;
            }
        }
Beispiel #25
0
        public static Error build_extension_error(Display display, Data data, 
    int code, int seq_no, int bad, int minor_opcode, int major_opcode)
        {
            gnu.x11.extension.ErrorFactory factory = display
              .extension_error_factories [code-128];

            if (factory == null)
              throw new gnu.x11.Error ("Unsupported extension error: " + code);

            return factory.build (display, data, code, seq_no, bad,
              minor_opcode, major_opcode);
        }
Beispiel #26
0
        private static void init()
        {
            lock(m_lock) {
            if(m_initialized) return;
            m_initialized=true;
            byte [] [] [] pixels;

            pixels = new byte [SIZE][][];

            for (int i=0; i<SIZE; i++)
            {
            pixels[i]= new byte[SIZE][];
              for (int j=0; j<SIZE; j++) {
            bool b1 = (i & 0x8) == 0;
            bool b2 = (j & 0x8) == 0;
            int c = (b1 && !b2) || (!b1 && b2) ? 255 : 0;
            pixels[i][j]=new byte[4];
            pixels [i] [j] [0] = (byte) c;
            pixels [i] [j] [1] = (byte) c;
            pixels [i] [j] [2] = (byte) c;
            pixels [i] [j] [3] = (byte) 255;
              }
            }
            m_PIXELS = new Data (pixels);

            pixels = new byte [SIZE][][];

            for (int i=0; i<SIZE; i++) {
            pixels[i]= new byte[SIZE][];
              for (int j=0; j<SIZE; j++) {
            bool b1 = (i & 0x8) == 0;
            bool b2 = (j & 0x8) == 0;
            int c = (b1 && !b2) || (!b1 && b2) ? 255 : 0;
            pixels[i][j]=new byte[4];
            pixels [i] [j] [0] = (byte) c;
            pixels [i] [j] [1] = (byte) 0;
            pixels [i] [j] [2] = (byte) 0;
            pixels [i] [j] [3] = (byte) 255;
              }
            }
            m_RED_PIXELS = new Data (pixels);

            pixels = new byte [SIZE][][];

            for (int i=0; i<SIZE; i++) {
            pixels[i]= new byte[SIZE][];
              for (int j=0; j<SIZE; j++) {
            bool b1 = (i & 0x8) == 0;
            bool b2 = (j & 0x8) == 0;
            int c = (b1 && !b2) || (!b1 && b2) ? 255 : 0;

            pixels[i][j]=new byte[3];
            pixels [i] [j] [0] = (byte) c;
            pixels [i] [j] [1] = (byte) c;
            pixels [i] [j] [2] = (byte) c;
              }
            }
            m_RGB_PIXELS = new Data (pixels);

            pixels = new byte [SUB_SIZE][][];

            for (int i=0; i<SUB_SIZE; i++) {
            pixels[i]= new byte[SUB_SIZE][];
              for (int j=0; j<SUB_SIZE; j++) {
            bool b1 = (i & 0x4) == 0;
            bool b2 = (j & 0x4) == 0;
            int c = (b1 && !b2) || (!b1 && b2) ? 255 : 0;
            pixels[i][j]=new byte[4];
            pixels [i] [j] [0] = (byte) c;
            pixels [i] [j] [1] = (byte) 0;
            pixels [i] [j] [2] = (byte) 0;
            pixels [i] [j] [3] = (byte) 255;
              }
            }
            m_SUB_PIXELS = new Data (pixels);
              }
        }
Beispiel #27
0
 public InputFocusReply(Display display, Data data)
     : base(data)
 {
     this.display = display;
 }
Beispiel #28
0
 /** Reading. */
 public Data(Data data)
     : this(data.data)
 {
     this.offset = data.offset;
 }
Beispiel #29
0
 public PointerControlReply(Data data)
     : base(data)
 {
 }
Beispiel #30
0
 /** Offset Reading. */
 public Data(Data data, int offset)
     : this(data)
 {
     this.offset += offset;
 }