1 |
/* -*- c-basic-offset: 8 -*- |
/* -*- c-basic-offset: 8 -*- |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
User interface services - X Window System |
User interface services - X Window System |
4 |
Copyright (C) Matthew Chapman 1999-2002 |
Copyright (C) Matthew Chapman 1999-2005 |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
32 |
extern int g_height; |
extern int g_height; |
33 |
extern int g_xpos; |
extern int g_xpos; |
34 |
extern int g_ypos; |
extern int g_ypos; |
35 |
|
extern int g_pos; |
36 |
extern BOOL g_sendmotion; |
extern BOOL g_sendmotion; |
37 |
extern BOOL g_fullscreen; |
extern BOOL g_fullscreen; |
38 |
extern BOOL g_grab_keyboard; |
extern BOOL g_grab_keyboard; |
120 |
XFillRectangle(g_display, g_ownbackstore ? g_backstore : g_wnd, g_gc, x, y, cx, cy); \ |
XFillRectangle(g_display, g_ownbackstore ? g_backstore : g_wnd, g_gc, x, y, cx, cy); \ |
121 |
} |
} |
122 |
|
|
123 |
|
#define FILL_POLYGON(p,np)\ |
124 |
|
{ \ |
125 |
|
XFillPolygon(g_display, g_wnd, g_gc, p, np, Complex, CoordModePrevious); \ |
126 |
|
if (g_ownbackstore) \ |
127 |
|
XFillPolygon(g_display, g_backstore, g_gc, p, np, Complex, CoordModePrevious); \ |
128 |
|
} |
129 |
|
|
130 |
|
#define DRAW_ELLIPSE(x,y,cx,cy,m)\ |
131 |
|
{ \ |
132 |
|
switch (m) \ |
133 |
|
{ \ |
134 |
|
case 0: /* Outline */ \ |
135 |
|
XDrawArc(g_display, g_wnd, g_gc, x, y, cx, cy, 0, 360*64); \ |
136 |
|
if (g_ownbackstore) \ |
137 |
|
XDrawArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \ |
138 |
|
break; \ |
139 |
|
case 1: /* Filled */ \ |
140 |
|
XFillArc(g_display, g_ownbackstore ? g_backstore : g_wnd, g_gc, x, y, \ |
141 |
|
cx, cy, 0, 360*64); \ |
142 |
|
if (g_ownbackstore) \ |
143 |
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); \ |
144 |
|
break; \ |
145 |
|
} \ |
146 |
|
} |
147 |
|
|
148 |
/* colour maps */ |
/* colour maps */ |
149 |
extern BOOL g_owncolmap; |
extern BOOL g_owncolmap; |
150 |
static Colormap g_xcolmap; |
static Colormap g_xcolmap; |
688 |
} |
} |
689 |
else |
else |
690 |
{ |
{ |
691 |
|
while (out < end) |
692 |
{ |
{ |
693 |
pixel = *(data++); |
pixel = *(data++); |
694 |
SPLITCOLOUR16(pixel, pc); |
SPLITCOLOUR16(pixel, pc); |
791 |
if (g_arch_match) |
if (g_arch_match) |
792 |
{ |
{ |
793 |
/* *INDENT-OFF* */ |
/* *INDENT-OFF* */ |
794 |
|
#ifdef NEED_ALIGN |
795 |
REPEAT4 |
REPEAT4 |
796 |
( |
( |
|
#ifdef NEED_ALIGN |
|
797 |
*(out++) = *(data++); |
*(out++) = *(data++); |
798 |
*(out++) = *(data++); |
*(out++) = *(data++); |
799 |
*(out++) = *(data++); |
*(out++) = *(data++); |
800 |
*(out++) = 0; |
*(out++) = 0; |
801 |
|
) |
802 |
#else |
#else |
803 |
|
REPEAT4 |
804 |
|
( |
805 |
*((uint32 *) out) = *((uint32 *) data); |
*((uint32 *) out) = *((uint32 *) data); |
806 |
out += 4; |
out += 4; |
807 |
data += 3; |
data += 3; |
|
#endif |
|
808 |
) |
) |
809 |
|
#endif |
810 |
/* *INDENT-ON* */ |
/* *INDENT-ON* */ |
811 |
} |
} |
812 |
else if (g_xserver_be) |
else if (g_xserver_be) |
1164 |
wndwidth = g_fullscreen ? WidthOfScreen(g_screen) : g_width; |
wndwidth = g_fullscreen ? WidthOfScreen(g_screen) : g_width; |
1165 |
wndheight = g_fullscreen ? HeightOfScreen(g_screen) : g_height; |
wndheight = g_fullscreen ? HeightOfScreen(g_screen) : g_height; |
1166 |
|
|
1167 |
|
/* Handle -x-y portion of geometry string */ |
1168 |
|
if (g_xpos < 0 || (g_xpos == 0 && (g_pos & 2))) |
1169 |
|
g_xpos = WidthOfScreen(g_screen) + g_xpos - g_width; |
1170 |
|
if (g_ypos < 0 || (g_ypos == 0 && (g_pos & 4))) |
1171 |
|
g_ypos = HeightOfScreen(g_screen) + g_ypos - g_height; |
1172 |
|
|
1173 |
attribs.background_pixel = BlackPixelOfScreen(g_screen); |
attribs.background_pixel = BlackPixelOfScreen(g_screen); |
1174 |
attribs.border_pixel = WhitePixelOfScreen(g_screen); |
attribs.border_pixel = WhitePixelOfScreen(g_screen); |
1175 |
attribs.backing_store = g_ownbackstore ? NotUseful : Always; |
attribs.backing_store = g_ownbackstore ? NotUseful : Always; |
1213 |
if (sizehints) |
if (sizehints) |
1214 |
{ |
{ |
1215 |
sizehints->flags = PMinSize | PMaxSize; |
sizehints->flags = PMinSize | PMaxSize; |
1216 |
|
if (g_pos) |
1217 |
|
sizehints->flags |= PPosition; |
1218 |
sizehints->min_width = sizehints->max_width = g_width; |
sizehints->min_width = sizehints->max_width = g_width; |
1219 |
sizehints->min_height = sizehints->max_height = g_height; |
sizehints->min_height = sizehints->max_height = g_height; |
1220 |
XSetWMNormalHints(g_display, g_wnd, sizehints); |
XSetWMNormalHints(g_display, g_wnd, sizehints); |
1341 |
} |
} |
1342 |
} |
} |
1343 |
|
|
1344 |
/* Process all events in Xlib queue |
/* Process events in Xlib queue |
1345 |
Returns 0 after user quit, 1 otherwise */ |
Returns 0 after user quit, 1 otherwise */ |
1346 |
static int |
static int |
1347 |
xwin_process_events(void) |
xwin_process_events(void) |
1353 |
key_translation tr; |
key_translation tr; |
1354 |
char str[256]; |
char str[256]; |
1355 |
Status status; |
Status status; |
1356 |
|
int events = 0; |
1357 |
|
|
1358 |
while (XPending(g_display) > 0) |
while ((XPending(g_display) > 0) && events++ < 20) |
1359 |
{ |
{ |
1360 |
XNextEvent(g_display, &xevent); |
XNextEvent(g_display, &xevent); |
1361 |
|
|
2201 |
FILL_RECTANGLE(x, y, cx, cy); |
FILL_RECTANGLE(x, y, cx, cy); |
2202 |
} |
} |
2203 |
|
|
2204 |
|
void |
2205 |
|
ui_polygon(uint8 opcode, |
2206 |
|
/* mode */ uint8 fillmode, |
2207 |
|
/* dest */ POINT * point, int npoints, |
2208 |
|
/* brush */ BRUSH * brush, int bgcolour, int fgcolour) |
2209 |
|
{ |
2210 |
|
uint8 style, i, ipattern[8]; |
2211 |
|
Pixmap fill; |
2212 |
|
|
2213 |
|
SET_FUNCTION(opcode); |
2214 |
|
|
2215 |
|
switch (fillmode) |
2216 |
|
{ |
2217 |
|
case ALTERNATE: |
2218 |
|
XSetFillRule(g_display, g_gc, EvenOddRule); |
2219 |
|
break; |
2220 |
|
case WINDING: |
2221 |
|
XSetFillRule(g_display, g_gc, WindingRule); |
2222 |
|
break; |
2223 |
|
default: |
2224 |
|
unimpl("fill mode %d\n", fillmode); |
2225 |
|
} |
2226 |
|
|
2227 |
|
if (brush) |
2228 |
|
style = brush->style; |
2229 |
|
else |
2230 |
|
style = 0; |
2231 |
|
|
2232 |
|
switch (style) |
2233 |
|
{ |
2234 |
|
case 0: /* Solid */ |
2235 |
|
SET_FOREGROUND(fgcolour); |
2236 |
|
FILL_POLYGON((XPoint *) point, npoints); |
2237 |
|
break; |
2238 |
|
|
2239 |
|
case 2: /* Hatch */ |
2240 |
|
fill = (Pixmap) ui_create_glyph(8, 8, |
2241 |
|
hatch_patterns + brush->pattern[0] * 8); |
2242 |
|
SET_FOREGROUND(fgcolour); |
2243 |
|
SET_BACKGROUND(bgcolour); |
2244 |
|
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
2245 |
|
XSetStipple(g_display, g_gc, fill); |
2246 |
|
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
2247 |
|
FILL_POLYGON((XPoint *) point, npoints); |
2248 |
|
XSetFillStyle(g_display, g_gc, FillSolid); |
2249 |
|
XSetTSOrigin(g_display, g_gc, 0, 0); |
2250 |
|
ui_destroy_glyph((HGLYPH) fill); |
2251 |
|
break; |
2252 |
|
|
2253 |
|
case 3: /* Pattern */ |
2254 |
|
for (i = 0; i != 8; i++) |
2255 |
|
ipattern[7 - i] = brush->pattern[i]; |
2256 |
|
fill = (Pixmap) ui_create_glyph(8, 8, ipattern); |
2257 |
|
SET_FOREGROUND(bgcolour); |
2258 |
|
SET_BACKGROUND(fgcolour); |
2259 |
|
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
2260 |
|
XSetStipple(g_display, g_gc, fill); |
2261 |
|
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
2262 |
|
FILL_POLYGON((XPoint *) point, npoints); |
2263 |
|
XSetFillStyle(g_display, g_gc, FillSolid); |
2264 |
|
XSetTSOrigin(g_display, g_gc, 0, 0); |
2265 |
|
ui_destroy_glyph((HGLYPH) fill); |
2266 |
|
break; |
2267 |
|
|
2268 |
|
default: |
2269 |
|
unimpl("brush %d\n", brush->style); |
2270 |
|
} |
2271 |
|
|
2272 |
|
RESET_FUNCTION(opcode); |
2273 |
|
} |
2274 |
|
|
2275 |
|
void |
2276 |
|
ui_polyline(uint8 opcode, |
2277 |
|
/* dest */ POINT * points, int npoints, |
2278 |
|
/* pen */ PEN * pen) |
2279 |
|
{ |
2280 |
|
/* TODO: set join style */ |
2281 |
|
SET_FUNCTION(opcode); |
2282 |
|
SET_FOREGROUND(pen->colour); |
2283 |
|
XDrawLines(g_display, g_wnd, g_gc, (XPoint *) points, npoints, CoordModePrevious); |
2284 |
|
if (g_ownbackstore) |
2285 |
|
XDrawLines(g_display, g_backstore, g_gc, (XPoint *) points, npoints, |
2286 |
|
CoordModePrevious); |
2287 |
|
RESET_FUNCTION(opcode); |
2288 |
|
} |
2289 |
|
|
2290 |
|
void |
2291 |
|
ui_ellipse(uint8 opcode, |
2292 |
|
/* mode */ uint8 fillmode, |
2293 |
|
/* dest */ int x, int y, int cx, int cy, |
2294 |
|
/* brush */ BRUSH * brush, int bgcolour, int fgcolour) |
2295 |
|
{ |
2296 |
|
uint8 style, i, ipattern[8]; |
2297 |
|
Pixmap fill; |
2298 |
|
|
2299 |
|
SET_FUNCTION(opcode); |
2300 |
|
|
2301 |
|
if (brush) |
2302 |
|
style = brush->style; |
2303 |
|
else |
2304 |
|
style = 0; |
2305 |
|
|
2306 |
|
switch (style) |
2307 |
|
{ |
2308 |
|
case 0: /* Solid */ |
2309 |
|
SET_FOREGROUND(fgcolour); |
2310 |
|
DRAW_ELLIPSE(x, y, cx, cy, fillmode); |
2311 |
|
break; |
2312 |
|
|
2313 |
|
case 2: /* Hatch */ |
2314 |
|
fill = (Pixmap) ui_create_glyph(8, 8, |
2315 |
|
hatch_patterns + brush->pattern[0] * 8); |
2316 |
|
SET_FOREGROUND(fgcolour); |
2317 |
|
SET_BACKGROUND(bgcolour); |
2318 |
|
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
2319 |
|
XSetStipple(g_display, g_gc, fill); |
2320 |
|
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
2321 |
|
DRAW_ELLIPSE(x, y, cx, cy, fillmode); |
2322 |
|
XSetFillStyle(g_display, g_gc, FillSolid); |
2323 |
|
XSetTSOrigin(g_display, g_gc, 0, 0); |
2324 |
|
ui_destroy_glyph((HGLYPH) fill); |
2325 |
|
break; |
2326 |
|
|
2327 |
|
case 3: /* Pattern */ |
2328 |
|
for (i = 0; i != 8; i++) |
2329 |
|
ipattern[7 - i] = brush->pattern[i]; |
2330 |
|
fill = (Pixmap) ui_create_glyph(8, 8, ipattern); |
2331 |
|
SET_FOREGROUND(bgcolour); |
2332 |
|
SET_BACKGROUND(fgcolour); |
2333 |
|
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
2334 |
|
XSetStipple(g_display, g_gc, fill); |
2335 |
|
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
2336 |
|
DRAW_ELLIPSE(x, y, cx, cy, fillmode); |
2337 |
|
XSetFillStyle(g_display, g_gc, FillSolid); |
2338 |
|
XSetTSOrigin(g_display, g_gc, 0, 0); |
2339 |
|
ui_destroy_glyph((HGLYPH) fill); |
2340 |
|
break; |
2341 |
|
|
2342 |
|
default: |
2343 |
|
unimpl("brush %d\n", brush->style); |
2344 |
|
} |
2345 |
|
|
2346 |
|
RESET_FUNCTION(opcode); |
2347 |
|
} |
2348 |
|
|
2349 |
/* warning, this function only draws on wnd or backstore, not both */ |
/* warning, this function only draws on wnd or backstore, not both */ |
2350 |
void |
void |
2351 |
ui_draw_glyph(int mixmode, |
ui_draw_glyph(int mixmode, |
2401 |
} |
} |
2402 |
|
|
2403 |
void |
void |
2404 |
ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y, |
ui_draw_text(uint8 font, uint8 flags, uint8 opcode, int mixmode, int x, int y, |
2405 |
int clipx, int clipy, int clipcx, int clipcy, |
int clipx, int clipy, int clipcx, int clipcy, |
2406 |
int boxx, int boxy, int boxcx, int boxcy, int bgcolour, |
int boxx, int boxy, int boxcx, int boxcy, BRUSH * brush, |
2407 |
int fgcolour, uint8 * text, uint8 length) |
int bgcolour, int fgcolour, uint8 * text, uint8 length) |
2408 |
{ |
{ |
2409 |
|
/* TODO: use brush appropriately */ |
2410 |
|
|
2411 |
FONTGLYPH *glyph; |
FONTGLYPH *glyph; |
2412 |
int i, j, xyoffset, x1, y1; |
int i, j, xyoffset, x1, y1; |
2413 |
DATABLOB *entry; |
DATABLOB *entry; |