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