30 |
|
|
31 |
extern int g_width; |
extern int g_width; |
32 |
extern int g_height; |
extern int g_height; |
33 |
|
extern int g_xpos; |
34 |
|
extern int g_ypos; |
35 |
extern BOOL g_sendmotion; |
extern BOOL g_sendmotion; |
36 |
extern BOOL g_fullscreen; |
extern BOOL g_fullscreen; |
37 |
extern BOOL g_grab_keyboard; |
extern BOOL g_grab_keyboard; |
47 |
Window g_wnd; |
Window g_wnd; |
48 |
extern uint32 g_embed_wnd; |
extern uint32 g_embed_wnd; |
49 |
BOOL g_enable_compose = False; |
BOOL g_enable_compose = False; |
50 |
|
BOOL g_Unobscured; /* used for screenblt */ |
51 |
static GC g_gc = NULL; |
static GC g_gc = NULL; |
52 |
|
static GC g_create_bitmap_gc = NULL; |
53 |
|
static GC g_create_glyph_gc = NULL; |
54 |
static Visual *g_visual; |
static Visual *g_visual; |
55 |
static int g_depth; |
static int g_depth; |
56 |
static int g_bpp; |
static int g_bpp; |
176 |
split_colour15(uint32 colour) |
split_colour15(uint32 colour) |
177 |
{ |
{ |
178 |
PixelColour rv; |
PixelColour rv; |
179 |
rv.red = (colour & 0x7c00) >> 7; |
rv.red = ((colour >> 7) & 0xf8) | ((colour >> 12) & 0x7); |
180 |
rv.green = (colour & 0x03e0) >> 2; |
rv.green = ((colour >> 2) & 0xf8) | ((colour >> 8) & 0x7); |
181 |
rv.blue = (colour & 0x001f) << 3; |
rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7); |
182 |
return rv; |
return rv; |
183 |
} |
} |
184 |
|
|
186 |
split_colour16(uint32 colour) |
split_colour16(uint32 colour) |
187 |
{ |
{ |
188 |
PixelColour rv; |
PixelColour rv; |
189 |
rv.red = (colour & 0xf800) >> 8; |
rv.red = ((colour >> 8) & 0xf8) | ((colour >> 13) & 0x7); |
190 |
rv.green = (colour & 0x07e0) >> 3; |
rv.green = ((colour >> 3) & 0xfc) | ((colour >> 9) & 0x3); |
191 |
rv.blue = (colour & 0x001f) << 3; |
rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7); |
192 |
return rv; |
return rv; |
193 |
} |
} |
194 |
|
|
234 |
return make_colour(pc); |
return make_colour(pc); |
235 |
} |
} |
236 |
|
|
237 |
|
/* indent is confused by UNROLL8 */ |
238 |
|
/* *INDENT-OFF* */ |
239 |
|
|
240 |
|
/* repeat and unroll, similar to bitmap.c */ |
241 |
|
/* potentialy any of the following translate */ |
242 |
|
/* functions can use repeat but just doing */ |
243 |
|
/* the most common ones */ |
244 |
|
|
245 |
#define UNROLL8(stm) { stm stm stm stm stm stm stm stm } |
#define UNROLL8(stm) { stm stm stm stm stm stm stm stm } |
246 |
#define REPEAT(stm) \ |
/* 2 byte output repeat */ |
247 |
|
#define REPEAT2(stm) \ |
248 |
|
{ \ |
249 |
|
while (out <= end - 8 * 2) \ |
250 |
|
UNROLL8(stm) \ |
251 |
|
while (out < end) \ |
252 |
|
{ stm } \ |
253 |
|
} |
254 |
|
/* 4 byte output repeat */ |
255 |
|
#define REPEAT4(stm) \ |
256 |
{ \ |
{ \ |
257 |
while (out <= end - 8 * 4) \ |
while (out <= end - 8 * 4) \ |
258 |
UNROLL8(stm) \ |
UNROLL8(stm) \ |
273 |
uint16 value; |
uint16 value; |
274 |
|
|
275 |
if (g_arch_match) |
if (g_arch_match) |
276 |
REPEAT(*(((uint16*)out)++) = g_colmap[*(data++)];) |
{ |
277 |
|
REPEAT2 |
278 |
|
( |
279 |
|
*((uint16 *) out) = g_colmap[*(data++)]; |
280 |
|
out += 2; |
281 |
|
) |
282 |
|
} |
283 |
else if (g_xserver_be) |
else if (g_xserver_be) |
284 |
{ |
{ |
285 |
while (out < end) |
while (out < end) |
334 |
uint32 value; |
uint32 value; |
335 |
|
|
336 |
if (g_arch_match) |
if (g_arch_match) |
337 |
REPEAT(*(((uint32*)out)++) = g_colmap[*(data++)];) |
{ |
338 |
|
REPEAT4 |
339 |
|
( |
340 |
|
*((uint32 *) out) = g_colmap[*(data++)]; |
341 |
|
out += 4; |
342 |
|
) |
343 |
|
} |
344 |
else if (g_xserver_be) |
else if (g_xserver_be) |
345 |
{ |
{ |
346 |
while (out < end) |
while (out < end) |
365 |
} |
} |
366 |
} |
} |
367 |
|
|
368 |
|
/* *INDENT-ON* */ |
369 |
|
|
370 |
static void |
static void |
371 |
translate15to16(uint16 * data, uint8 * out, uint8 * end) |
translate15to16(uint16 * data, uint8 * out, uint8 * end) |
372 |
{ |
{ |
948 |
ui_create_window(void) |
ui_create_window(void) |
949 |
{ |
{ |
950 |
uint8 null_pointer_mask[1] = { 0x80 }; |
uint8 null_pointer_mask[1] = { 0x80 }; |
951 |
uint8 null_pointer_data[4] = { 0x00, 0x00, 0x00, 0x00 }; |
uint8 null_pointer_data[24] = { 0x00 }; |
952 |
|
|
953 |
XSetWindowAttributes attribs; |
XSetWindowAttributes attribs; |
954 |
XClassHint *classhints; |
XClassHint *classhints; |
955 |
XSizeHints *sizehints; |
XSizeHints *sizehints; |
966 |
attribs.override_redirect = g_fullscreen; |
attribs.override_redirect = g_fullscreen; |
967 |
attribs.colormap = g_xcolmap; |
attribs.colormap = g_xcolmap; |
968 |
|
|
969 |
g_wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), 0, 0, wndwidth, wndheight, |
g_wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), g_xpos, g_ypos, wndwidth, |
970 |
0, g_depth, InputOutput, g_visual, |
wndheight, 0, g_depth, InputOutput, g_visual, |
971 |
CWBackPixel | CWBackingStore | CWOverrideRedirect | |
CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap | |
972 |
CWColormap | CWBorderPixel, &attribs); |
CWBorderPixel, &attribs); |
973 |
|
|
974 |
if (g_gc == NULL) |
if (g_gc == NULL) |
975 |
g_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
g_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
976 |
|
|
977 |
|
if (g_create_bitmap_gc == NULL) |
978 |
|
g_create_bitmap_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
979 |
|
|
980 |
if ((g_ownbackstore) && (g_backstore == 0)) |
if ((g_ownbackstore) && (g_backstore == 0)) |
981 |
{ |
{ |
982 |
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); |
1045 |
XMaskEvent(g_display, VisibilityChangeMask, &xevent); |
XMaskEvent(g_display, VisibilityChangeMask, &xevent); |
1046 |
} |
} |
1047 |
while (xevent.type != VisibilityNotify); |
while (xevent.type != VisibilityNotify); |
1048 |
|
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; |
1049 |
|
|
1050 |
g_focused = False; |
g_focused = False; |
1051 |
g_mouse_in_wnd = False; |
g_mouse_in_wnd = False; |
1066 |
ui_resize_window() |
ui_resize_window() |
1067 |
{ |
{ |
1068 |
XSizeHints *sizehints; |
XSizeHints *sizehints; |
1069 |
|
Pixmap bs; |
1070 |
|
|
1071 |
sizehints = XAllocSizeHints(); |
sizehints = XAllocSizeHints(); |
1072 |
if (sizehints) |
if (sizehints) |
1082 |
{ |
{ |
1083 |
XResizeWindow(g_display, g_wnd, g_width, g_height); |
XResizeWindow(g_display, g_wnd, g_width, g_height); |
1084 |
} |
} |
1085 |
|
|
1086 |
|
/* create new backstore pixmap */ |
1087 |
|
if (g_backstore != 0) |
1088 |
|
{ |
1089 |
|
bs = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth); |
1090 |
|
XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen)); |
1091 |
|
XFillRectangle(g_display, bs, g_gc, 0, 0, g_width, g_height); |
1092 |
|
XCopyArea(g_display, g_backstore, bs, g_gc, 0, 0, g_width, g_height, 0, 0); |
1093 |
|
XFreePixmap(g_display, g_backstore); |
1094 |
|
g_backstore = bs; |
1095 |
|
} |
1096 |
} |
} |
1097 |
|
|
1098 |
void |
void |
1156 |
|
|
1157 |
switch (xevent.type) |
switch (xevent.type) |
1158 |
{ |
{ |
1159 |
|
case VisibilityNotify: |
1160 |
|
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; |
1161 |
|
break; |
1162 |
case ClientMessage: |
case ClientMessage: |
1163 |
/* the window manager told us to quit */ |
/* the window manager told us to quit */ |
1164 |
if ((xevent.xclient.message_type == g_protocol_atom) |
if ((xevent.xclient.message_type == g_protocol_atom) |
1437 |
error("select: %s\n", strerror(errno)); |
error("select: %s\n", strerror(errno)); |
1438 |
|
|
1439 |
case 0: |
case 0: |
1440 |
/* TODO: if tv.tv_sec just times out |
/* Abort serial read calls */ |
1441 |
* we will segfault. |
if (s_timeout) |
1442 |
* FIXME: |
rdpdr_check_fds(&rfds, &wfds, (BOOL) True); |
|
*/ |
|
|
//s_timeout = True; |
|
|
//rdpdr_check_fds(&rfds, &wfds, (BOOL) True); |
|
1443 |
continue; |
continue; |
1444 |
} |
} |
1445 |
|
|
1486 |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0, |
1487 |
(char *) tdata, width, height, bitmap_pad, 0); |
(char *) tdata, width, height, bitmap_pad, 0); |
1488 |
|
|
1489 |
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); |
1490 |
|
|
1491 |
XFree(image); |
XFree(image); |
1492 |
if (tdata != data) |
if (tdata != data) |
1544 |
XImage *image; |
XImage *image; |
1545 |
Pixmap bitmap; |
Pixmap bitmap; |
1546 |
int scanline; |
int scanline; |
|
GC gc; |
|
1547 |
|
|
1548 |
scanline = (width + 7) / 8; |
scanline = (width + 7) / 8; |
1549 |
|
|
1550 |
bitmap = XCreatePixmap(g_display, g_wnd, width, height, 1); |
bitmap = XCreatePixmap(g_display, g_wnd, width, height, 1); |
1551 |
gc = XCreateGC(g_display, bitmap, 0, NULL); |
if (g_create_glyph_gc == 0) |
1552 |
|
g_create_glyph_gc = XCreateGC(g_display, bitmap, 0, NULL); |
1553 |
|
|
1554 |
image = XCreateImage(g_display, g_visual, 1, ZPixmap, 0, (char *) data, |
image = XCreateImage(g_display, g_visual, 1, ZPixmap, 0, (char *) data, |
1555 |
width, height, 8, scanline); |
width, height, 8, scanline); |
1557 |
image->bitmap_bit_order = MSBFirst; |
image->bitmap_bit_order = MSBFirst; |
1558 |
XInitImage(image); |
XInitImage(image); |
1559 |
|
|
1560 |
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); |
1561 |
|
|
1562 |
XFree(image); |
XFree(image); |
|
XFreeGC(g_display, gc); |
|
1563 |
return (HGLYPH) bitmap; |
return (HGLYPH) bitmap; |
1564 |
} |
} |
1565 |
|
|
1901 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
1902 |
if (g_ownbackstore) |
if (g_ownbackstore) |
1903 |
{ |
{ |
1904 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
if (g_Unobscured) |
1905 |
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, y); |
{ |
1906 |
|
XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
1907 |
|
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, |
1908 |
|
y); |
1909 |
|
} |
1910 |
|
else |
1911 |
|
{ |
1912 |
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
1913 |
|
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, |
1914 |
|
y); |
1915 |
|
} |
1916 |
} |
} |
1917 |
else |
else |
1918 |
{ |
{ |
2187 |
|
|
2188 |
XFree(image); |
XFree(image); |
2189 |
} |
} |
2190 |
|
|
2191 |
|
/* these do nothing here but are used in uiports */ |
2192 |
|
void |
2193 |
|
ui_begin_update(void) |
2194 |
|
{ |
2195 |
|
} |
2196 |
|
|
2197 |
|
void |
2198 |
|
ui_end_update(void) |
2199 |
|
{ |
2200 |
|
} |