45 |
Window g_wnd; |
Window g_wnd; |
46 |
extern uint32 g_embed_wnd; |
extern uint32 g_embed_wnd; |
47 |
BOOL g_enable_compose = False; |
BOOL g_enable_compose = False; |
48 |
|
BOOL g_Unobscured; /* used for screenblt */ |
49 |
static GC g_gc = NULL; |
static GC g_gc = NULL; |
50 |
|
static GC g_create_bitmap_gc = NULL; |
51 |
|
static GC g_create_glyph_gc = NULL; |
52 |
static Visual *g_visual; |
static Visual *g_visual; |
53 |
static int g_depth; |
static int g_depth; |
54 |
static int g_bpp; |
static int g_bpp; |
174 |
split_colour15(uint32 colour) |
split_colour15(uint32 colour) |
175 |
{ |
{ |
176 |
PixelColour rv; |
PixelColour rv; |
177 |
rv.red = (colour & 0x7c00) >> 7; |
rv.red = ((colour >> 7) & 0xf8) | ((colour >> 12) & 0x7); |
178 |
rv.green = (colour & 0x03e0) >> 2; |
rv.green = ((colour >> 2) & 0xf8) | ((colour >> 8) & 0x7); |
179 |
rv.blue = (colour & 0x001f) << 3; |
rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7); |
180 |
return rv; |
return rv; |
181 |
} |
} |
182 |
|
|
184 |
split_colour16(uint32 colour) |
split_colour16(uint32 colour) |
185 |
{ |
{ |
186 |
PixelColour rv; |
PixelColour rv; |
187 |
rv.red = (colour & 0xf800) >> 8; |
rv.red = ((colour >> 8) & 0xf8) | ((colour >> 13) & 0x7); |
188 |
rv.green = (colour & 0x07e0) >> 3; |
rv.green = ((colour >> 3) & 0xfc) | ((colour >> 9) & 0x3); |
189 |
rv.blue = (colour & 0x001f) << 3; |
rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7); |
190 |
return rv; |
return rv; |
191 |
} |
} |
192 |
|
|
232 |
return make_colour(pc); |
return make_colour(pc); |
233 |
} |
} |
234 |
|
|
235 |
|
/* indent is confused by UNROLL8 */ |
236 |
|
/* *INDENT-OFF* */ |
237 |
|
|
238 |
|
/* repeat and unroll, similar to bitmap.c */ |
239 |
|
/* potentialy any of the following translate */ |
240 |
|
/* functions can use repeat but just doing */ |
241 |
|
/* the most common ones */ |
242 |
|
|
243 |
|
#define UNROLL8(stm) { stm stm stm stm stm stm stm stm } |
244 |
|
/* 2 byte output repeat */ |
245 |
|
#define REPEAT2(stm) \ |
246 |
|
{ \ |
247 |
|
while (out <= end - 8 * 2) \ |
248 |
|
UNROLL8(stm) \ |
249 |
|
while (out < end) \ |
250 |
|
{ stm } \ |
251 |
|
} |
252 |
|
/* 4 byte output repeat */ |
253 |
|
#define REPEAT4(stm) \ |
254 |
|
{ \ |
255 |
|
while (out <= end - 8 * 4) \ |
256 |
|
UNROLL8(stm) \ |
257 |
|
while (out < end) \ |
258 |
|
{ stm } \ |
259 |
|
} |
260 |
|
|
261 |
static void |
static void |
262 |
translate8to8(uint8 * data, uint8 * out, uint8 * end) |
translate8to8(uint8 * data, uint8 * out, uint8 * end) |
263 |
{ |
{ |
270 |
{ |
{ |
271 |
uint16 value; |
uint16 value; |
272 |
|
|
273 |
if (g_xserver_be) |
if (g_arch_match) |
274 |
|
{ |
275 |
|
REPEAT2 |
276 |
|
( |
277 |
|
*((uint16 *) out) = g_colmap[*(data++)]; |
278 |
|
out += 2; |
279 |
|
) |
280 |
|
} |
281 |
|
else if (g_xserver_be) |
282 |
{ |
{ |
283 |
while (out < end) |
while (out < end) |
284 |
{ |
{ |
331 |
{ |
{ |
332 |
uint32 value; |
uint32 value; |
333 |
|
|
334 |
if (g_xserver_be) |
if (g_arch_match) |
335 |
|
{ |
336 |
|
REPEAT4 |
337 |
|
( |
338 |
|
*((uint32 *) out) = g_colmap[*(data++)]; |
339 |
|
out += 4; |
340 |
|
) |
341 |
|
} |
342 |
|
else if (g_xserver_be) |
343 |
{ |
{ |
344 |
while (out < end) |
while (out < end) |
345 |
{ |
{ |
363 |
} |
} |
364 |
} |
} |
365 |
|
|
366 |
|
/* *INDENT-ON* */ |
367 |
|
|
368 |
static void |
static void |
369 |
translate15to16(uint16 * data, uint8 * out, uint8 * end) |
translate15to16(uint16 * data, uint8 * out, uint8 * end) |
370 |
{ |
{ |
946 |
ui_create_window(void) |
ui_create_window(void) |
947 |
{ |
{ |
948 |
uint8 null_pointer_mask[1] = { 0x80 }; |
uint8 null_pointer_mask[1] = { 0x80 }; |
949 |
uint8 null_pointer_data[4] = { 0x00, 0x00, 0x00, 0x00 }; |
uint8 null_pointer_data[24] = { 0x00 }; |
950 |
|
|
951 |
XSetWindowAttributes attribs; |
XSetWindowAttributes attribs; |
952 |
XClassHint *classhints; |
XClassHint *classhints; |
953 |
XSizeHints *sizehints; |
XSizeHints *sizehints; |
972 |
if (g_gc == NULL) |
if (g_gc == NULL) |
973 |
g_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
g_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
974 |
|
|
975 |
|
if (g_create_bitmap_gc == NULL) |
976 |
|
g_create_bitmap_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
977 |
|
|
978 |
if ((g_ownbackstore) && (g_backstore == 0)) |
if ((g_ownbackstore) && (g_backstore == 0)) |
979 |
{ |
{ |
980 |
g_backstore = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth); |
g_backstore = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth); |
1043 |
XMaskEvent(g_display, VisibilityChangeMask, &xevent); |
XMaskEvent(g_display, VisibilityChangeMask, &xevent); |
1044 |
} |
} |
1045 |
while (xevent.type != VisibilityNotify); |
while (xevent.type != VisibilityNotify); |
1046 |
|
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; |
1047 |
|
|
1048 |
g_focused = False; |
g_focused = False; |
1049 |
g_mouse_in_wnd = False; |
g_mouse_in_wnd = False; |
1061 |
} |
} |
1062 |
|
|
1063 |
void |
void |
1064 |
|
ui_resize_window() |
1065 |
|
{ |
1066 |
|
XSizeHints *sizehints; |
1067 |
|
Pixmap bs; |
1068 |
|
|
1069 |
|
sizehints = XAllocSizeHints(); |
1070 |
|
if (sizehints) |
1071 |
|
{ |
1072 |
|
sizehints->flags = PMinSize | PMaxSize; |
1073 |
|
sizehints->min_width = sizehints->max_width = g_width; |
1074 |
|
sizehints->min_height = sizehints->max_height = g_height; |
1075 |
|
XSetWMNormalHints(g_display, g_wnd, sizehints); |
1076 |
|
XFree(sizehints); |
1077 |
|
} |
1078 |
|
|
1079 |
|
if (!(g_fullscreen || g_embed_wnd)) |
1080 |
|
{ |
1081 |
|
XResizeWindow(g_display, g_wnd, g_width, g_height); |
1082 |
|
} |
1083 |
|
|
1084 |
|
/* create new backstore pixmap */ |
1085 |
|
if (g_backstore != 0) |
1086 |
|
{ |
1087 |
|
bs = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth); |
1088 |
|
XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen)); |
1089 |
|
XFillRectangle(g_display, bs, g_gc, 0, 0, g_width, g_height); |
1090 |
|
XCopyArea(g_display, g_backstore, bs, g_gc, 0, 0, g_width, g_height, 0, 0); |
1091 |
|
XFreePixmap(g_display, g_backstore); |
1092 |
|
g_backstore = bs; |
1093 |
|
} |
1094 |
|
} |
1095 |
|
|
1096 |
|
void |
1097 |
ui_destroy_window(void) |
ui_destroy_window(void) |
1098 |
{ |
{ |
1099 |
if (g_IC != NULL) |
if (g_IC != NULL) |
1154 |
|
|
1155 |
switch (xevent.type) |
switch (xevent.type) |
1156 |
{ |
{ |
1157 |
|
case VisibilityNotify: |
1158 |
|
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; |
1159 |
|
break; |
1160 |
case ClientMessage: |
case ClientMessage: |
1161 |
/* the window manager told us to quit */ |
/* the window manager told us to quit */ |
1162 |
if ((xevent.xclient.message_type == g_protocol_atom) |
if ((xevent.xclient.message_type == g_protocol_atom) |
1435 |
error("select: %s\n", strerror(errno)); |
error("select: %s\n", strerror(errno)); |
1436 |
|
|
1437 |
case 0: |
case 0: |
1438 |
/* TODO: if tv.tv_sec just times out |
/* Abort serial read calls */ |
1439 |
* we will segfault. |
if (s_timeout) |
1440 |
* FIXME: |
rdpdr_check_fds(&rfds, &wfds, (BOOL) True); |
|
*/ |
|
|
//s_timeout = True; |
|
|
//rdpdr_check_fds(&rfds, &wfds, (BOOL) True); |
|
1441 |
continue; |
continue; |
1442 |
} |
} |
1443 |
|
|
1484 |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
1485 |
(char *) tdata, width, height, bitmap_pad, 0); |
(char *) tdata, width, height, bitmap_pad, 0); |
1486 |
|
|
1487 |
XPutImage(g_display, bitmap, g_gc, image, 0, 0, 0, 0, width, height); |
XPutImage(g_display, bitmap, g_create_bitmap_gc, image, 0, 0, 0, 0, width, height); |
1488 |
|
|
1489 |
XFree(image); |
XFree(image); |
1490 |
if (tdata != data) |
if (tdata != data) |
1542 |
XImage *image; |
XImage *image; |
1543 |
Pixmap bitmap; |
Pixmap bitmap; |
1544 |
int scanline; |
int scanline; |
|
GC gc; |
|
1545 |
|
|
1546 |
scanline = (width + 7) / 8; |
scanline = (width + 7) / 8; |
1547 |
|
|
1548 |
bitmap = XCreatePixmap(g_display, g_wnd, width, height, 1); |
bitmap = XCreatePixmap(g_display, g_wnd, width, height, 1); |
1549 |
gc = XCreateGC(g_display, bitmap, 0, NULL); |
if (g_create_glyph_gc == 0) |
1550 |
|
g_create_glyph_gc = XCreateGC(g_display, bitmap, 0, NULL); |
1551 |
|
|
1552 |
image = XCreateImage(g_display, g_visual, 1, ZPixmap, 0, (char *) data, |
image = XCreateImage(g_display, g_visual, 1, ZPixmap, 0, (char *) data, |
1553 |
width, height, 8, scanline); |
width, height, 8, scanline); |
1555 |
image->bitmap_bit_order = MSBFirst; |
image->bitmap_bit_order = MSBFirst; |
1556 |
XInitImage(image); |
XInitImage(image); |
1557 |
|
|
1558 |
XPutImage(g_display, bitmap, gc, image, 0, 0, 0, 0, width, height); |
XPutImage(g_display, bitmap, g_create_glyph_gc, image, 0, 0, 0, 0, width, height); |
1559 |
|
|
1560 |
XFree(image); |
XFree(image); |
|
XFreeGC(g_display, gc); |
|
1561 |
return (HGLYPH) bitmap; |
return (HGLYPH) bitmap; |
1562 |
} |
} |
1563 |
|
|
1849 |
{ |
{ |
1850 |
case 0: /* Solid */ |
case 0: /* Solid */ |
1851 |
SET_FOREGROUND(fgcolour); |
SET_FOREGROUND(fgcolour); |
1852 |
FILL_RECTANGLE(x, y, cx, cy); |
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
1853 |
break; |
break; |
1854 |
|
|
1855 |
case 2: /* Hatch */ |
case 2: /* Hatch */ |
1860 |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
1861 |
XSetStipple(g_display, g_gc, fill); |
XSetStipple(g_display, g_gc, fill); |
1862 |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
1863 |
FILL_RECTANGLE(x, y, cx, cy); |
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
1864 |
XSetFillStyle(g_display, g_gc, FillSolid); |
XSetFillStyle(g_display, g_gc, FillSolid); |
1865 |
XSetTSOrigin(g_display, g_gc, 0, 0); |
XSetTSOrigin(g_display, g_gc, 0, 0); |
1866 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((HGLYPH) fill); |
1870 |
for (i = 0; i != 8; i++) |
for (i = 0; i != 8; i++) |
1871 |
ipattern[7 - i] = brush->pattern[i]; |
ipattern[7 - i] = brush->pattern[i]; |
1872 |
fill = (Pixmap) ui_create_glyph(8, 8, ipattern); |
fill = (Pixmap) ui_create_glyph(8, 8, ipattern); |
|
|
|
1873 |
SET_FOREGROUND(bgcolour); |
SET_FOREGROUND(bgcolour); |
1874 |
SET_BACKGROUND(fgcolour); |
SET_BACKGROUND(fgcolour); |
1875 |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
1876 |
XSetStipple(g_display, g_gc, fill); |
XSetStipple(g_display, g_gc, fill); |
1877 |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
1878 |
|
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
|
FILL_RECTANGLE(x, y, cx, cy); |
|
|
|
|
1879 |
XSetFillStyle(g_display, g_gc, FillSolid); |
XSetFillStyle(g_display, g_gc, FillSolid); |
1880 |
XSetTSOrigin(g_display, g_gc, 0, 0); |
XSetTSOrigin(g_display, g_gc, 0, 0); |
1881 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((HGLYPH) fill); |
1886 |
} |
} |
1887 |
|
|
1888 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
1889 |
|
|
1890 |
|
if (g_ownbackstore) |
1891 |
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); |
1892 |
} |
} |
1893 |
|
|
1894 |
void |
void |
1899 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
1900 |
if (g_ownbackstore) |
if (g_ownbackstore) |
1901 |
{ |
{ |
1902 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
if (g_Unobscured) |
1903 |
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, y); |
{ |
1904 |
|
XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
1905 |
|
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, |
1906 |
|
y); |
1907 |
|
} |
1908 |
|
else |
1909 |
|
{ |
1910 |
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
1911 |
|
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, |
1912 |
|
y); |
1913 |
|
} |
1914 |
} |
} |
1915 |
else |
else |
1916 |
{ |
{ |
2185 |
|
|
2186 |
XFree(image); |
XFree(image); |
2187 |
} |
} |
2188 |
|
|
2189 |
|
/* these do nothing here but are used in uiports */ |
2190 |
|
void |
2191 |
|
ui_begin_update(void) |
2192 |
|
{ |
2193 |
|
} |
2194 |
|
|
2195 |
|
void |
2196 |
|
ui_end_update(void) |
2197 |
|
{ |
2198 |
|
} |