2
Copyright (c) 2009 Jay Sorg
3
Copyright (c) 2010 Vic Lee
5
Permission is hereby granted, free of charge, to any person obtaining a
6
copy of this software and associated documentation files (the "Software"),
7
to deal in the Software without restriction, including without limitation
8
the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
and/or sell copies of the Software, and to permit persons to whom the
10
Software is furnished to do so, subject to the following conditions:
12
The above copyright notice and this permission notice shall be included
13
in all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
DEALINGS IN THE SOFTWARE.
32
extern LPCTSTR g_wnd_class_name;
33
extern HINSTANCE g_hInstance;
34
extern HCURSOR g_default_cursor;
36
// See http://msdn.microsoft.com/en-us/library/dd145130(VS.85).aspx
37
static const DWORD rop3_code_table[] =
45
0x00060865, // PDSxnon
50
0x000B0B2A, // PSDnaon
52
0x000D0B25, // PDSnaon
53
0x000E08A5, // PDSonon
57
0x00120868, // SDPxnon
59
0x00140869, // DPSxnon
61
0x00165CCA, // PSDPSanaxx
62
0x00171D54, // SSPxDSxaxn
63
0x00180D59, // SPxPDxa
64
0x00191CC8, // SDPSanaxn
65
0x001A06C5, // PDSPaox
66
0x001B0768, // SDPSxaxn
67
0x001C06CA, // PSDPaox
68
0x001D0766, // DSPDxaxn
74
0x00230B24, // SPDnaon
75
0x00240D55, // SPxDSxa
76
0x00251CC5, // PDSPanaxn
77
0x002606C8, // SDPSaox
78
0x00271868, // SDPSxnox
80
0x002916CA, // PSDPSaoxxn
82
0x002B1D58, // SSPxPDxaxn
83
0x002C0784, // SPDSoax
85
0x002E064A, // PSDPxox
86
0x002F0E2A, // PSDnoan
88
0x00310B28, // SDPnaon
89
0x00320688, // SDPSoox
91
0x003406C4, // SPDSaox
92
0x00351864, // SPDSxnox
95
0x0038078A, // PSDPoax
97
0x003A0644, // SPDSxox
98
0x003B0E24, // SPDnoan
100
0x003D18A4, // SPDSonox
101
0x003E1B24, // SPDSnaox
103
0x00400F0A, // PSDnaa
104
0x00410249, // DPSxon
105
0x00420D5D, // SDxPDxa
106
0x00431CC4, // SPDSanaxn
108
0x00450B29, // DPSnaon
109
0x004606C6, // DSPDaox
110
0x0047076A, // PSDPxaxn
112
0x004916C5, // PDSPDaoxxn
113
0x004A0789, // DPSDoax
114
0x004B0605, // PDSnox
115
0x004C0CC8, // SDPana
116
0x004D1954, // SSPxDSxoxn
117
0x004E0645, // PDSPxox
118
0x004F0E25, // PDSnoan
120
0x00510B26, // DSPnaon
121
0x005206C9, // DPSDaox
122
0x00530764, // SPDSxaxn
123
0x005408A9, // DPSonon
126
0x00570389, // DPSoan
127
0x00580785, // PDSPoax
128
0x00590609, // DPSnox
130
0x005B18A9, // DPSDonox
131
0x005C0649, // DPSDxox
132
0x005D0E29, // DPSnoan
133
0x005E1B29, // DPSDnaox
136
0x006116C6, // DSPDSaoxxn
137
0x00620786, // DSPDoax
138
0x00630608, // SDPnox
139
0x00640788, // SDPSoax
140
0x00650606, // DSPnox
142
0x006718A8, // SDPSonox
143
0x006858A6, // DSPDSonoxxn
144
0x00690145, // PDSxxn
146
0x006B178A, // PSDPSoaxxn
148
0x006D1785, // PDSPDoaxxn
149
0x006E1E28, // SDPSnoax
150
0x006F0C65, // PDSxnan
151
0x00700CC5, // PDSana
152
0x00711D5C, // SSDxPDxaxn
153
0x00720648, // SDPSxox
154
0x00730E28, // SDPnoan
155
0x00740646, // DSPDxox
156
0x00750E26, // DSPnoan
157
0x00761B28, // SDPSnaox
160
0x00791786, // DSPDSoaxxn
161
0x007A1E29, // DPSDnoax
162
0x007B0C68, // SDPxnan
163
0x007C1E24, // SPDSnoax
164
0x007D0C69, // DPSxnan
165
0x007E0955, // SPxDSxo
166
0x007F03C9, // DPSaan
168
0x00810975, // SPxDSxon
169
0x00820C49, // DPSxna
170
0x00831E04, // SPDSnoaxn
171
0x00840C48, // SDPxna
172
0x00851E05, // PDSPnoaxn
173
0x008617A6, // DSPDSoaxx
174
0x008701C5, // PDSaxn
176
0x00891B08, // SDPSnaoxn
177
0x008A0E06, // DSPnoa
178
0x008B0666, // DSPDxoxn
179
0x008C0E08, // SDPnoa
180
0x008D0668, // SDPSxoxn
181
0x008E1D7C, // SSDxPDxax
182
0x008F0CE5, // PDSanan
183
0x00900C45, // PDSxna
184
0x00911E08, // SDPSnoaxn
185
0x009217A9, // DPSDPoaxx
186
0x009301C4, // SPDaxn
187
0x009417AA, // PSDPSoaxx
188
0x009501C9, // DPSaxn
190
0x0097588A, // PSDPSonoxx
191
0x00981888, // SDPSonoxn
193
0x009A0709, // DPSnax
194
0x009B07A8, // SDPSoaxn
195
0x009C0704, // SPDnax
196
0x009D07A6, // DSPDoaxn
197
0x009E16E6, // DSPDSaoxx
198
0x009F0345, // PDSxan
200
0x00A11B05, // PDSPnaoxn
201
0x00A20E09, // DPSnoa
202
0x00A30669, // DPSDxoxn
203
0x00A41885, // PDSPonoxn
205
0x00A60706, // DSPnax
206
0x00A707A5, // PDSPoaxn
208
0x00A90189, // DPSoxn
210
0x00AB0889, // DPSono
211
0x00AC0744, // SPDSxax
212
0x00AD06E9, // DPSDaoxn
213
0x00AE0B06, // DSPnao
215
0x00B00E05, // PDSnoa
216
0x00B10665, // PDSPxoxn
217
0x00B21974, // SSPxDSxox
218
0x00B30CE8, // SDPanan
219
0x00B4070A, // PSDnax
220
0x00B507A9, // DPSDoaxn
221
0x00B616E9, // DPSDPaoxx
222
0x00B70348, // SDPxan
223
0x00B8074A, // PSDPxax
224
0x00B906E6, // DSPDaoxn
225
0x00BA0B09, // DPSnao
227
0x00BC1CE4, // SPDSanax
228
0x00BD0D7D, // SDxPDxan
230
0x00BF08C9, // DPSano
232
0x00C11B04, // SPDSnaoxn
233
0x00C21884, // SPDSonoxn
235
0x00C40E04, // SPDnoa
236
0x00C50664, // SPDSxoxn
237
0x00C60708, // SDPnax
238
0x00C707AA, // PSDPoaxn
240
0x00C90184, // SPDoxn
241
0x00CA0749, // DPSDxax
242
0x00CB06E4, // SPDSaoxn
244
0x00CD0888, // SDPono
245
0x00CE0B08, // SDPnao
247
0x00D00E0A, // PSDnoa
248
0x00D1066A, // PSDPxoxn
249
0x00D20705, // PDSnax
250
0x00D307A4, // SPDSoaxn
251
0x00D41D78, // SSPxPDxax
252
0x00D50CE9, // DPSanan
253
0x00D616EA, // PSDPSaoxx
254
0x00D70349, // DPSxan
255
0x00D80745, // PDSPxax
256
0x00D906E8, // SDPSaoxn
257
0x00DA1CE9, // DPSDanax
258
0x00DB0D75, // SPxDSxan
259
0x00DC0B04, // SPDnao
262
0x00DF08C8, // SDPano
264
0x00E10185, // PDSoxn
265
0x00E20746, // DSPDxax
266
0x00E306EA, // PSDPaoxn
267
0x00E40748, // SDPSxax
268
0x00E506E5, // PDSPaoxn
269
0x00E61CE8, // SDPSanax
270
0x00E70D79, // SPxPDxan
271
0x00E81D74, // SSPxDSxax
272
0x00E95CE6, // DSPDSanaxxn
274
0x00EB0849, // DPSxno
276
0x00ED0848, // SDPxno
278
0x00EF0A08, // SDPnoo
280
0x00F10885, // PDSono
281
0x00F20B05, // PDSnao
283
0x00F40B0A, // PSDnao
286
0x00F708C5, // PDSano
288
0x00F90845, // PDSxno
290
0x00FB0A09, // DPSnoo
292
0x00FD0A0A, // PSDnoo
298
wf_invalidate_region(wfInfo * wfi, int x1, int y1, int x2, int y2)
300
if (wfi->update_pending)
302
wfi->update_rect.left = min(x1, wfi->update_rect.left);
303
wfi->update_rect.top = min(y1, wfi->update_rect.top);
304
wfi->update_rect.right = max(x2, wfi->update_rect.right);
305
wfi->update_rect.bottom = max(y2, wfi->update_rect.bottom);
309
wfi->update_pending = 1;
310
wfi->update_rect.left = x1;
311
wfi->update_rect.top = y1;
312
wfi->update_rect.right = x2;
313
wfi->update_rect.bottom = y2;
318
wf_create_dib(wfInfo * wfi, int width, int height, int bpp, int reverse, uint8 * data)
322
BITMAPINFO bmi = {0};
326
bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
327
bmi.bmiHeader.biWidth = width;
328
bmi.bmiHeader.biHeight = height;
329
bmi.bmiHeader.biPlanes = 1;
330
bmi.bmiHeader.biBitCount = 24;
331
bmi.bmiHeader.biCompression = BI_RGB;
332
bitmap = CreateDIBSection (hdc, &bmi, DIB_RGB_COLORS, (void**)&cdata, NULL, 0);
335
wf_image_convert(wfi, width, height, bpp, reverse, data, cdata);
337
ReleaseDC(NULL, hdc);
343
wf_create_brush(wfInfo * wfi, RD_BRUSH * brush, int color, int bpp)
347
HBITMAP pattern = NULL;
353
lbr.lbStyle = brush->style;
355
if (lbr.lbStyle == BS_DIBPATTERN || lbr.lbStyle == BS_DIBPATTERN8X8 || lbr.lbStyle == BS_DIBPATTERNPT)
357
lbr.lbColor = DIB_RGB_COLORS;
364
if (lbr.lbStyle == BS_PATTERN || lbr.lbStyle == BS_PATTERN8X8)
366
if (brush->bd == 0) /* rdp4 brush */
368
for (i = 0; i != 8; i++)
370
ipattern[7 - i] = brush->pattern[i];
372
cdata = wf_glyph_convert(wfi, 8, 8, ipattern);
373
pattern = CreateBitmap(8, 8, 1, 1, cdata);
374
lbr.lbHatch = (ULONG_PTR)pattern;
377
else if (brush->bd->color_code > 1) /* > 1 bpp */
379
pattern = wf_create_dib(wfi, 8, 8, bpp, 1, brush->bd->data);
380
lbr.lbHatch = (ULONG_PTR)pattern;
384
cdata = wf_glyph_convert(wfi, 8, 8, brush->bd->data);
385
pattern = CreateBitmap(8, 8, 1, 1, cdata);
386
lbr.lbHatch = (ULONG_PTR)pattern;
390
else if (lbr.lbStyle == BS_HATCHED)
392
lbr.lbHatch = brush->pattern[0];
399
br = CreateBrushIndirect(&lbr);
400
SetBrushOrgEx(wfi->drw->hdc, brush->xorigin, brush->yorigin, NULL);
403
DeleteObject(pattern);
408
static struct wf_bitmap *
409
wf_bitmap_new(wfInfo * wfi, int width, int height, int bpp, int reverse, uint8 * data)
411
struct wf_bitmap *bm;
415
bm = (struct wf_bitmap *) malloc(sizeof(struct wf_bitmap));
416
bm->hdc = CreateCompatibleDC(hdc);
419
bm->bitmap = CreateCompatibleBitmap(hdc, width, height);
423
bm->bitmap = wf_create_dib(wfi, width, height, bpp, reverse, data);
425
bm->org_bitmap = (HBITMAP)SelectObject(bm->hdc, bm->bitmap);
426
ReleaseDC(NULL, hdc);
431
wf_bitmap_free(struct wf_bitmap * bm)
435
SelectObject(bm->hdc, bm->org_bitmap);
436
DeleteObject(bm->bitmap);
443
l_ui_error(struct rdp_inst * inst, char * text)
445
printf("ui_error: %s", text);
449
l_ui_warning(struct rdp_inst * inst, char * text)
451
printf("ui_warning: %s\n", text);
455
l_ui_unimpl(struct rdp_inst * inst, char * text)
457
printf("ui_unimpl: %s\n", text);
461
l_ui_begin_update(struct rdp_inst * inst)
463
//printf("ui_begin_update\n");
467
l_ui_end_update(struct rdp_inst * inst)
469
//printf("ui_end_update\n");
473
l_ui_desktop_save(struct rdp_inst * inst, int offset, int x, int y,
476
printf("ui_desktop_save:\n");
480
l_ui_desktop_restore(struct rdp_inst * inst, int offset, int x, int y,
483
printf("ui_desktop_restore:\n");
487
l_ui_create_glyph(struct rdp_inst * inst, int width, int height, uint8 * data)
492
struct wf_bitmap * bm;
496
bm = (struct wf_bitmap *) malloc(sizeof(struct wf_bitmap));
497
bm->hdc = CreateCompatibleDC(hdc);
498
cdata = wf_glyph_convert(wfi, width, height, data);
499
bm->bitmap = CreateBitmap(width, height, 1, 1, cdata);
500
bm->org_bitmap = (HBITMAP)SelectObject(bm->hdc, bm->bitmap);
502
ReleaseDC(NULL, hdc);
503
return (RD_HGLYPH)bm;
507
l_ui_destroy_glyph(struct rdp_inst * inst, RD_HGLYPH glyph)
509
wf_bitmap_free((struct wf_bitmap *) glyph);
513
l_ui_create_bitmap(struct rdp_inst * inst, int width, int height, uint8 * data)
516
struct wf_bitmap * bm;
519
bm = wf_bitmap_new(wfi, width, height, inst->settings->server_depth, 1, data);
520
return (RD_HBITMAP) bm;
524
l_ui_destroy_bitmap(struct rdp_inst * inst, RD_HBITMAP bmp)
526
wf_bitmap_free((struct wf_bitmap *) bmp);
530
l_ui_paint_bitmap(struct rdp_inst * inst, int x, int y, int cx, int cy, int width,
531
int height, uint8 * data)
534
struct wf_bitmap * bm;
537
//printf("ui_paint_bitmap x %d y %d cx %d cy %d width %d height %d\n", x, y, cx, cy, width, height);
538
bm = (struct wf_bitmap *) l_ui_create_bitmap(inst, width, height, data);
539
BitBlt(wfi->backstore->hdc, x, y, cx, cy, bm->hdc, 0, 0, SRCCOPY);
541
wf_invalidate_region(wfi, x, y, x + cx, y + cy);
545
l_ui_line(struct rdp_inst * inst, uint8 opcode, int startx, int starty, int endx,
546
int endy, RD_PEN * pen)
555
//printf("ui_line opcode %d startx %d starty %d endx %d endy %d\n", opcode, startx, starty, endx, endy);
556
color = wf_color_convert(wfi, pen->color, inst->settings->server_depth);
557
hpen = CreatePen(pen->style, pen->width, color);
558
org_rop2 = SetROP2(wfi->drw->hdc, opcode + 1);
559
org_hpen = (HPEN)SelectObject(wfi->drw->hdc, hpen);
560
MoveToEx(wfi->drw->hdc, startx, starty, NULL);
561
LineTo(wfi->drw->hdc, endx, endy);
562
SelectObject(wfi->drw->hdc, org_hpen);
563
SetROP2 (wfi->drw->hdc, org_rop2);
565
if (wfi->drw == wfi->backstore)
567
wf_invalidate_region(wfi, min(startx, endx), min(starty, endy), max(startx, endx), max(starty, endy));
572
l_ui_rect(struct rdp_inst * inst, int x, int y, int cx, int cy, int color)
579
color = wf_color_convert(wfi, color, inst->settings->server_depth);
580
//printf("ui_rect %i %i %i %i %i\n", x, y, cx, cy, color);
584
rect.bottom = y + cy;
585
brush = CreateSolidBrush(color);
586
FillRect(wfi->drw->hdc, &rect, brush);
588
if (wfi->drw == wfi->backstore)
590
wf_invalidate_region(wfi, rect.left, rect.top, rect.right, rect.bottom);
595
l_ui_polygon(struct rdp_inst * inst, uint8 opcode, uint8 fillmode, RD_POINT * point,
596
int npoints, RD_BRUSH * brush, int bgcolor, int fgcolor)
598
printf("ui_polygon:\n");
602
l_ui_polyline(struct rdp_inst * inst, uint8 opcode, RD_POINT * points, int npoints,
614
//printf("ui_polyline opcode %d npoints %d\n", opcode, npoints);
615
color = wf_color_convert(wfi, pen->color, inst->settings->server_depth);
616
hpen = CreatePen(pen->style, pen->width, color);
617
org_rop2 = SetROP2(wfi->drw->hdc, opcode + 1);
618
org_hpen = (HPEN)SelectObject(wfi->drw->hdc, hpen);
621
ps = (POINT *) malloc(sizeof(POINT) * npoints);
622
for (i = 0; i < npoints; i++)
624
//printf("ui_polyline point %d %d %d\n", i, points[i].x, points[i].y);
627
ps[i].x = points[i].x;
628
ps[i].y = points[i].y;
632
ps[i].x = ps[i - 1].x + points[i].x;
633
ps[i].y = ps[i - 1].y + points[i].y;
635
if (wfi->drw == wfi->backstore)
637
wf_invalidate_region(wfi, ps[i].x, ps[i].y, ps[i].x + 1, ps[i].y + 1);
640
Polyline(wfi->drw->hdc, ps, npoints);
642
SelectObject(wfi->drw->hdc, org_hpen);
643
SetROP2 (wfi->drw->hdc, org_rop2);
648
l_ui_ellipse(struct rdp_inst * inst, uint8 opcode, uint8 fillmode, int x, int y,
649
int cx, int cy, RD_BRUSH * brush, int bgcolor, int fgcolor)
651
printf("ui_ellipse:\n");
655
l_ui_start_draw_glyphs(struct rdp_inst * inst, int bgcolor, int fgcolor)
660
wfi->brush = CreateSolidBrush(wf_color_convert(wfi, fgcolor, inst->settings->server_depth));
661
wfi->org_brush = (HBRUSH)SelectObject(wfi->drw->hdc, wfi->brush);
665
l_ui_draw_glyph(struct rdp_inst * inst, int x, int y, int cx, int cy,
669
struct wf_bitmap * bm;
672
bm = (struct wf_bitmap *) glyph;
673
BitBlt(wfi->drw->hdc, x, y, cx, cy, bm->hdc, 0, 0, 0x00E20746); // DSPDxax
675
if (wfi->drw == wfi->backstore)
677
wf_invalidate_region(wfi, x, y, x + cx, y + cy);
682
l_ui_end_draw_glyphs(struct rdp_inst * inst, int x, int y, int cx, int cy)
687
SelectObject(wfi->drw->hdc, wfi->org_brush);
688
DeleteObject(wfi->brush);
690
wfi->org_brush = NULL;
694
l_ui_get_toggle_keys_state(struct rdp_inst * inst)
698
if (GetKeyState(VK_SCROLL))
700
state |= KBD_SYNC_SCROLL_LOCK;
702
if (GetKeyState(VK_NUMLOCK))
704
state |= KBD_SYNC_NUM_LOCK;
706
if (GetKeyState(VK_CAPITAL))
708
state |= KBD_SYNC_CAPS_LOCK;
710
if (GetKeyState(VK_KANA))
712
state |= KBD_SYNC_KANA_LOCK;
718
l_ui_bell(struct rdp_inst * inst)
724
l_ui_destblt(struct rdp_inst * inst, uint8 opcode, int x, int y, int cx, int cy)
729
BitBlt(wfi->drw->hdc, x, y, cx, cy, NULL, 0, 0, rop3_code_table[opcode]);
730
if (wfi->drw == wfi->backstore)
732
wf_invalidate_region(wfi, x, y, x + cx, y + cy);
737
l_ui_patblt(struct rdp_inst * inst, uint8 opcode, int x, int y, int cx, int cy,
738
RD_BRUSH * brush, int bgcolor, int fgcolor)
744
COLORREF org_bkcolor;
745
COLORREF org_textcolor;
748
//printf("ui_patblt: style %d x %d y %d cx %d cy %d\n", brush->style, x, y, cx, cy);
749
bgcolor = wf_color_convert(wfi, bgcolor, inst->settings->server_depth);
750
fgcolor = wf_color_convert(wfi, fgcolor, inst->settings->server_depth);
752
br = wf_create_brush(wfi, brush, fgcolor, inst->settings->server_depth);
753
org_bkmode = SetBkMode(wfi->drw->hdc, OPAQUE);
754
org_bkcolor = SetBkColor(wfi->drw->hdc, bgcolor);
755
org_textcolor = SetTextColor(wfi->drw->hdc, fgcolor);
756
org_br = (HBRUSH)SelectObject(wfi->drw->hdc, br);
757
PatBlt(wfi->drw->hdc, x, y, cx, cy, rop3_code_table[opcode]);
758
SelectObject(wfi->drw->hdc, org_br);
760
SetBkMode(wfi->drw->hdc, org_bkmode);
761
SetBkColor(wfi->drw->hdc, org_bkcolor);
762
SetTextColor(wfi->drw->hdc, org_textcolor);
763
if (wfi->drw == wfi->backstore)
765
wf_invalidate_region(wfi, x, y, x + cx, y + cy);
770
l_ui_screenblt(struct rdp_inst * inst, uint8 opcode, int x, int y, int cx, int cy,
776
//printf("ui_screenblt: opcode %d x %d y %d cx %d cy %d srcx %d srcy%d \n", opcode, x, y, cx, cy, srcx, srcy);
777
BitBlt(wfi->drw->hdc, x, y, cx, cy, wfi->backstore->hdc, srcx, srcy, rop3_code_table[opcode]);
778
if (wfi->drw == wfi->backstore)
780
wf_invalidate_region(wfi, x, y, x + cx, y + cy);
785
l_ui_memblt(struct rdp_inst * inst, uint8 opcode, int x, int y, int cx, int cy,
786
RD_HBITMAP src, int srcx, int srcy)
789
struct wf_bitmap * bm;
792
bm = (struct wf_bitmap *) src;
793
//printf("ui_memblt %i %i %i %i %i %i %i\n", x, y, cx, cy, srcx, srcy, opcode);
794
BitBlt(wfi->drw->hdc, x, y, cx, cy, bm->hdc, srcx, srcy, rop3_code_table[opcode]);
795
if (wfi->drw == wfi->backstore)
797
wf_invalidate_region(wfi, x, y, x + cx, y + cy);
802
l_ui_triblt(struct rdp_inst * inst, uint8 opcode, int x, int y, int cx, int cy,
803
RD_HBITMAP src, int srcx, int srcy, RD_BRUSH * brush, int bgcolor, int fgcolor)
808
printf("ui_triblt\n");
813
l_ui_select(struct rdp_inst * inst, int rdp_socket)
815
//printf("ui_select: inst %p\n", inst);
820
l_ui_set_clip(struct rdp_inst * inst, int x, int y, int cx, int cy)
826
//printf("ui_set_clip %i %i %i %i\n", x, y, cx, cy);
827
hrgn = CreateRectRgn(x, y, x + cx, y + cy);
828
SelectClipRgn(wfi->drw->hdc, hrgn);
833
l_ui_reset_clip(struct rdp_inst * inst)
838
//printf("ui_reset_clip\n");
839
SelectClipRgn(wfi->drw->hdc, NULL);
843
l_ui_resize_window(struct rdp_inst * inst)
845
printf("ui_resize_window:\n");
849
l_ui_set_cursor(struct rdp_inst * inst, RD_HCURSOR cursor)
854
wfi->cursor = (HCURSOR)cursor;
855
PostMessage(wfi->hwnd, WM_SETCURSOR, 0, 0);
859
l_ui_destroy_cursor(struct rdp_inst * inst, RD_HCURSOR cursor)
864
if (wfi->cursor == (HCURSOR)cursor)
866
wfi->cursor = g_default_cursor;
867
PostMessage(wfi->hwnd, WM_SETCURSOR, 0, 0);
869
DestroyCursor((HCURSOR)cursor);
873
l_ui_create_cursor(struct rdp_inst * inst, uint32 x, uint32 y,
874
int width, int height, uint8 * andmask, uint8 * xormask, int bpp)
884
cursor = CreateCursor(g_hInstance, x, y, width, height, andmask, xormask);
888
iconinfo.fIcon = FALSE;
889
iconinfo.xHotspot = x;
890
iconinfo.yHotspot = y;
891
cdata = wf_cursor_mask_convert(wfi, width, height, andmask);
892
iconinfo.hbmMask = CreateBitmap(width, height, 1, 1, cdata);
893
iconinfo.hbmColor = wf_create_dib(wfi, width, height, bpp, 0, xormask);
894
cursor = CreateIconIndirect(&iconinfo);
895
DeleteObject(iconinfo.hbmMask);
896
DeleteObject(iconinfo.hbmColor);
899
return (RD_HCURSOR)cursor;
903
l_ui_set_null_cursor(struct rdp_inst * inst)
909
PostMessage(wfi->hwnd, WM_SETCURSOR, 0, 0);
913
l_ui_set_default_cursor(struct rdp_inst * inst)
918
wfi->cursor = g_default_cursor;
919
PostMessage(wfi->hwnd, WM_SETCURSOR, 0, 0);
923
l_ui_create_colormap(struct rdp_inst * inst, RD_PALETTE * colors)
928
return wf_create_colormap(wfi, colors);
932
l_ui_move_pointer(struct rdp_inst * inst, int x, int y)
941
l_ui_set_colormap(struct rdp_inst * inst, RD_HPALETTE map)
946
wf_set_colormap(wfi, map);
950
l_ui_create_surface(struct rdp_inst * inst, int width, int height, RD_HBITMAP old_surface)
953
struct wf_bitmap * bm;
954
struct wf_bitmap * old_bm;
957
bm = wf_bitmap_new(wfi, width, height, 0, 0, NULL);
958
old_bm = (struct wf_bitmap *) old_surface;
961
BitBlt(bm->hdc, 0, 0, width, height, old_bm->hdc, 0, 0, SRCCOPY);
962
wf_bitmap_free(old_bm);
964
if (wfi->drw == old_bm)
968
return (RD_HBITMAP)bm;
972
l_ui_set_surface(struct rdp_inst * inst, RD_HBITMAP surface)
979
wfi->drw = (struct wf_bitmap *) surface;
983
wfi->drw = wfi->backstore;
988
l_ui_destroy_surface(struct rdp_inst * inst, RD_HBITMAP surface)
993
if (wfi->drw == surface)
995
l_ui_warning(inst, "ui_destroy_surface: freeing active surface!\n");
996
wfi->drw = wfi->backstore;
1000
wf_bitmap_free((struct wf_bitmap *)surface);
1005
l_ui_channel_data(struct rdp_inst * inst, int chan_id, char * data, int data_size,
1006
int flags, int total_size)
1012
wf_assign_callbacks(rdpInst * inst)
1014
inst->ui_error = l_ui_error;
1015
inst->ui_warning = l_ui_warning;
1016
inst->ui_unimpl = l_ui_unimpl;
1017
inst->ui_begin_update = l_ui_begin_update;
1018
inst->ui_end_update = l_ui_end_update;
1019
inst->ui_desktop_save = l_ui_desktop_save;
1020
inst->ui_desktop_restore = l_ui_desktop_restore;
1021
inst->ui_create_bitmap = l_ui_create_bitmap;
1022
inst->ui_paint_bitmap = l_ui_paint_bitmap;
1023
inst->ui_destroy_bitmap = l_ui_destroy_bitmap;
1024
inst->ui_line = l_ui_line;
1025
inst->ui_rect = l_ui_rect;
1026
inst->ui_polygon = l_ui_polygon;
1027
inst->ui_polyline = l_ui_polyline;
1028
inst->ui_ellipse = l_ui_ellipse;
1029
inst->ui_start_draw_glyphs = l_ui_start_draw_glyphs;
1030
inst->ui_draw_glyph = l_ui_draw_glyph;
1031
inst->ui_end_draw_glyphs = l_ui_end_draw_glyphs;
1032
inst->ui_get_toggle_keys_state = l_ui_get_toggle_keys_state;
1033
inst->ui_bell = l_ui_bell;
1034
inst->ui_destblt = l_ui_destblt;
1035
inst->ui_patblt = l_ui_patblt;
1036
inst->ui_screenblt = l_ui_screenblt;
1037
inst->ui_memblt = l_ui_memblt;
1038
inst->ui_triblt = l_ui_triblt;
1039
inst->ui_create_glyph = l_ui_create_glyph;
1040
inst->ui_destroy_glyph = l_ui_destroy_glyph;
1041
inst->ui_select = l_ui_select;
1042
inst->ui_set_clip = l_ui_set_clip;
1043
inst->ui_reset_clip = l_ui_reset_clip;
1044
inst->ui_resize_window = l_ui_resize_window;
1045
inst->ui_set_cursor = l_ui_set_cursor;
1046
inst->ui_destroy_cursor = l_ui_destroy_cursor;
1047
inst->ui_create_cursor = l_ui_create_cursor;
1048
inst->ui_set_null_cursor = l_ui_set_null_cursor;
1049
inst->ui_set_default_cursor = l_ui_set_default_cursor;
1050
inst->ui_create_colormap = l_ui_create_colormap;
1051
inst->ui_move_pointer = l_ui_move_pointer;
1052
inst->ui_set_colormap = l_ui_set_colormap;
1053
inst->ui_create_surface = l_ui_create_surface;
1054
inst->ui_set_surface = l_ui_set_surface;
1055
inst->ui_destroy_surface = l_ui_destroy_surface;
1056
inst->ui_channel_data = l_ui_channel_data;
1061
wf_pre_connect(rdpInst * inst, HWND hwnd)
1065
wf_assign_callbacks(inst);
1066
wfi = (wfInfo *) malloc(sizeof(wfInfo));
1068
memset(wfi, 0, sizeof(wfInfo));
1072
wfi->cursor = g_default_cursor;
1073
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)wfi);
1079
wf_post_connect(rdpInst * inst)
1084
RECT rc_client, rc_wnd;
1087
wfi = GET_WFI(inst);
1088
width = inst->settings->width;
1089
height = inst->settings->height;
1091
wfi->backstore = wf_bitmap_new(wfi, width, height, 0, 0, NULL);
1092
BitBlt(wfi->backstore->hdc, 0, 0, width, height, NULL, 0, 0, BLACKNESS);
1093
wfi->drw = wfi->backstore;
1095
GetClientRect(wfi->hwnd, &rc_client);
1096
GetWindowRect(wfi->hwnd, &rc_wnd);
1097
diff.x = (rc_wnd.right - rc_wnd.left) - rc_client.right;
1098
diff.y = (rc_wnd.bottom - rc_wnd.top) - rc_client.bottom;
1099
MoveWindow(wfi->hwnd, rc_wnd.left, rc_wnd.top, width + diff.x, height + diff.y, FALSE);
1100
ShowWindow(wfi->hwnd, SW_SHOWNORMAL);
1101
UpdateWindow(wfi->hwnd);
1107
wf_update_window(rdpInst * inst)
1111
wfi = GET_WFI(inst);
1112
if (wfi->update_pending)
1114
InvalidateRect(wfi->hwnd, &wfi->update_rect, FALSE);
1115
wfi->update_pending = 0;
1122
wf_uninit(rdpInst * inst)
1126
wfi = GET_WFI(inst);
1127
/* Inform the main thread to destroy the window */
1128
SetWindowLongPtr(wfi->hwnd, GWLP_USERDATA, -1);
1129
CloseWindow(wfi->hwnd);
1130
wf_bitmap_free(wfi->backstore);
1131
if (wfi->colormap != 0)
1133
free(wfi->colormap);