1 /* Copyright (c) 2006 Russ Cox */ 2 3 /* 4 5 tag[1] Rerror error[s] 6 7 tag[1] Trdmouse 8 tag[1] Rrdmouse x[4] y[4] button[4] msec[4] resized[1] 9 10 tag[1] Tmoveto x[4] y[4] 11 tag[1] Rmoveto 12 13 tag[1] Tcursor cursor[] 14 tag[1] Rcursor 15 16 tag[1] Tcursor2 cursor[] 17 tag[1] Rcursor2 18 19 tag[1] Tbouncemouse x[4] y[4] button[4] 20 tag[1] Rbouncemouse 21 22 tag[1] Trdkbd 23 tag[1] Rrdkbd rune[2] 24 25 tag[1] Trdkbd4 26 tag[1] Rrdkbd4 rune[4] 27 28 tag[1] Tlabel label[s] 29 tag[1] Rlabel 30 31 tag[1] Tctxt wsysid[s] 32 tag[1] Rctxt 33 34 tag[1] Tinit winsize[s] label[s] font[s] 35 tag[1] Rinit 36 37 tag[1] Trdsnarf 38 tag[1] Rrdsnarf snarf[s] 39 40 tag[1] Twrsnarf snarf[s] 41 tag[1] Rwrsnarf 42 43 tag[1] Trddraw count[4] 44 tag[1] Rrddraw count[4] data[count] 45 46 tag[1] Twrdraw count[4] data[count] 47 tag[1] Rwrdraw count[4] 48 49 tag[1] Ttop 50 tag[1] Rtop 51 52 tag[1] Tresize rect[4*4] 53 tag[1] Rresize 54 */ 55 56 57 #define PUT(p, x) \ 58 (p)[0] = ((x) >> 24)&0xFF, \ 59 (p)[1] = ((x) >> 16)&0xFF, \ 60 (p)[2] = ((x) >> 8)&0xFF, \ 61 (p)[3] = (x)&0xFF 62 63 #define GET(p, x) \ 64 ((x) = (u32int)(((p)[0] << 24) | ((p)[1] << 16) | ((p)[2] << 8) | ((p)[3]))) 65 66 #define PUT2(p, x) \ 67 (p)[0] = ((x) >> 8)&0xFF, \ 68 (p)[1] = (x)&0xFF 69 70 #define GET2(p, x) \ 71 ((x) = (((p)[0] << 8) | ((p)[1]))) 72 73 enum { 74 Rerror = 1, 75 Trdmouse = 2, 76 Rrdmouse, 77 Tmoveto = 4, 78 Rmoveto, 79 Tcursor = 6, 80 Rcursor, 81 Tbouncemouse = 8, 82 Rbouncemouse, 83 Trdkbd = 10, 84 Rrdkbd, 85 Tlabel = 12, 86 Rlabel, 87 Tinit = 14, 88 Rinit, 89 Trdsnarf = 16, 90 Rrdsnarf, 91 Twrsnarf = 18, 92 Rwrsnarf, 93 Trddraw = 20, 94 Rrddraw, 95 Twrdraw = 22, 96 Rwrdraw, 97 Ttop = 24, 98 Rtop, 99 Tresize = 26, 100 Rresize, 101 Tcursor2 = 28, 102 Rcursor2, 103 Tctxt = 30, 104 Rctxt, 105 Trdkbd4 = 32, 106 Rrdkbd4, 107 Tmax, 108 }; 109 110 enum { 111 MAXWMSG = 4*1024*1024 112 }; 113 114 typedef struct Wsysmsg Wsysmsg; 115 struct Wsysmsg 116 { 117 uchar type; 118 uchar tag; 119 Mouse mouse; 120 int resized; 121 Cursor cursor; 122 Cursor2 cursor2; 123 int arrowcursor; 124 Rune rune; 125 char *winsize; 126 char *label; 127 char *snarf; 128 char *error; 129 char *id; 130 uchar *data; 131 uint count; 132 Rectangle rect; 133 }; 134 135 uint convW2M(Wsysmsg*, uchar*, uint); 136 uint convM2W(uchar*, uint, Wsysmsg*); 137 uint sizeW2M(Wsysmsg*); 138 int readwsysmsg(int, uchar*, uint); 139 140 int drawfcallfmt(Fmt*); 141