43 |
static int g_x_socket; |
static int g_x_socket; |
44 |
static Screen *g_screen; |
static Screen *g_screen; |
45 |
Window g_wnd; |
Window g_wnd; |
46 |
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 Visual *g_visual; |
static Visual *g_visual; |
51 |
static int g_depth; |
static int g_depth; |
58 |
static Atom g_protocol_atom, g_kill_atom; |
static Atom g_protocol_atom, g_kill_atom; |
59 |
static BOOL g_focused; |
static BOOL g_focused; |
60 |
static BOOL g_mouse_in_wnd; |
static BOOL g_mouse_in_wnd; |
61 |
static BOOL g_arch_match = False; /* set to True if RGB XServer and little endian */ |
static BOOL g_arch_match = False; /* set to True if RGB XServer and little endian */ |
62 |
|
|
63 |
/* endianness */ |
/* endianness */ |
64 |
static BOOL g_host_be; |
static BOOL g_host_be; |
67 |
static int g_red_shift_l, g_blue_shift_l, g_green_shift_l; |
static int g_red_shift_l, g_blue_shift_l, g_green_shift_l; |
68 |
|
|
69 |
/* software backing store */ |
/* software backing store */ |
70 |
BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ |
extern BOOL g_ownbackstore; |
71 |
static Pixmap g_backstore = 0; |
static Pixmap g_backstore = 0; |
72 |
|
|
73 |
/* Moving in single app mode */ |
/* Moving in single app mode */ |
116 |
} |
} |
117 |
|
|
118 |
/* colour maps */ |
/* colour maps */ |
119 |
BOOL g_owncolmap = False; |
extern BOOL g_owncolmap; |
120 |
static Colormap g_xcolmap; |
static Colormap g_xcolmap; |
121 |
static uint32 *g_colmap = NULL; |
static uint32 *g_colmap = NULL; |
122 |
|
|
172 |
split_colour15(uint32 colour) |
split_colour15(uint32 colour) |
173 |
{ |
{ |
174 |
PixelColour rv; |
PixelColour rv; |
175 |
rv.red = (colour & 0x7c00) >> 7; |
rv.red = ((colour >> 7) & 0xf8) | ((colour >> 12) & 0x7); |
176 |
rv.green = (colour & 0x03e0) >> 2; |
rv.green = ((colour >> 2) & 0xf8) | ((colour >> 8) & 0x7); |
177 |
rv.blue = (colour & 0x001f) << 3; |
rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7); |
178 |
return rv; |
return rv; |
179 |
} |
} |
180 |
|
|
182 |
split_colour16(uint32 colour) |
split_colour16(uint32 colour) |
183 |
{ |
{ |
184 |
PixelColour rv; |
PixelColour rv; |
185 |
rv.red = (colour & 0xf800) >> 8; |
rv.red = ((colour >> 8) & 0xf8) | ((colour >> 13) & 0x7); |
186 |
rv.green = (colour & 0x07e0) >> 3; |
rv.green = ((colour >> 3) & 0xfc) | ((colour >> 9) & 0x3); |
187 |
rv.blue = (colour & 0x001f) << 3; |
rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7); |
188 |
return rv; |
return rv; |
189 |
} |
} |
190 |
|
|
230 |
return make_colour(pc); |
return make_colour(pc); |
231 |
} |
} |
232 |
|
|
233 |
|
#define UNROLL8(stm) { stm stm stm stm stm stm stm stm } |
234 |
|
#define REPEAT(stm) \ |
235 |
|
{ \ |
236 |
|
while (out <= end - 8 * 4) \ |
237 |
|
UNROLL8(stm) \ |
238 |
|
while (out < end) \ |
239 |
|
{ stm } \ |
240 |
|
} |
241 |
|
|
242 |
static void |
static void |
243 |
translate8to8(uint8 * data, uint8 * out, uint8 * end) |
translate8to8(uint8 * data, uint8 * out, uint8 * end) |
244 |
{ |
{ |
251 |
{ |
{ |
252 |
uint16 value; |
uint16 value; |
253 |
|
|
254 |
if (g_xserver_be) |
if (g_arch_match) |
255 |
|
REPEAT(*((uint16 *) out) = g_colmap[*(data++)]; |
256 |
|
out += 2;) |
257 |
|
else |
258 |
|
if (g_xserver_be) |
259 |
|
{ |
260 |
|
while (out < end) |
261 |
{ |
{ |
262 |
while (out < end) |
value = (uint16) g_colmap[*(data++)]; |
263 |
{ |
*(out++) = value >> 8; |
264 |
value = (uint16) g_colmap[*(data++)]; |
*(out++) = value; |
|
*(out++) = value >> 8; |
|
|
*(out++) = value; |
|
|
} |
|
265 |
} |
} |
266 |
else |
} |
267 |
|
else |
268 |
|
{ |
269 |
|
while (out < end) |
270 |
{ |
{ |
271 |
while (out < end) |
value = (uint16) g_colmap[*(data++)]; |
272 |
{ |
*(out++) = value; |
273 |
value = (uint16) g_colmap[*(data++)]; |
*(out++) = value >> 8; |
|
*(out++) = value; |
|
|
*(out++) = value >> 8; |
|
|
} |
|
274 |
} |
} |
275 |
} |
} |
276 |
|
} |
277 |
|
|
278 |
/* little endian - conversion happens when colourmap is built */ |
/* little endian - conversion happens when colourmap is built */ |
279 |
static void |
static void |
308 |
{ |
{ |
309 |
uint32 value; |
uint32 value; |
310 |
|
|
311 |
if (g_xserver_be) |
if (g_arch_match) |
312 |
|
REPEAT(*((uint32 *) out) = g_colmap[*(data++)]; |
313 |
|
out += 4;) |
314 |
|
else |
315 |
|
if (g_xserver_be) |
316 |
|
{ |
317 |
|
while (out < end) |
318 |
{ |
{ |
319 |
while (out < end) |
value = g_colmap[*(data++)]; |
320 |
{ |
*(out++) = value >> 24; |
321 |
value = g_colmap[*(data++)]; |
*(out++) = value >> 16; |
322 |
*(out++) = value >> 24; |
*(out++) = value >> 8; |
323 |
*(out++) = value >> 16; |
*(out++) = value; |
|
*(out++) = value >> 8; |
|
|
*(out++) = value; |
|
|
} |
|
324 |
} |
} |
325 |
else |
} |
326 |
|
else |
327 |
|
{ |
328 |
|
while (out < end) |
329 |
{ |
{ |
330 |
while (out < end) |
value = g_colmap[*(data++)]; |
331 |
{ |
*(out++) = value; |
332 |
value = g_colmap[*(data++)]; |
*(out++) = value >> 8; |
333 |
*(out++) = value; |
*(out++) = value >> 16; |
334 |
*(out++) = value >> 8; |
*(out++) = value >> 24; |
|
*(out++) = value >> 16; |
|
|
*(out++) = value >> 24; |
|
|
} |
|
335 |
} |
} |
336 |
} |
} |
337 |
|
} |
338 |
|
|
339 |
static void |
static void |
340 |
translate15to16(uint16 * data, uint8 * out, uint8 * end) |
translate15to16(uint16 * data, uint8 * out, uint8 * end) |
623 |
/* if server and xserver bpp match, */ |
/* if server and xserver bpp match, */ |
624 |
/* and arch(endian) matches, no need to translate */ |
/* and arch(endian) matches, no need to translate */ |
625 |
/* just return data */ |
/* just return data */ |
626 |
if (g_depth > 8) |
if (g_arch_match) |
627 |
if (g_arch_match) |
{ |
628 |
if (g_depth == g_server_bpp) |
if (g_depth == 15 && g_server_bpp == 15) |
629 |
return data; |
return data; |
630 |
|
if (g_depth == 16 && g_server_bpp == 16) |
631 |
|
return data; |
632 |
|
} |
633 |
|
|
634 |
size = width * height * (g_bpp / 8); |
size = width * height * (g_bpp / 8); |
635 |
out = (uint8 *) xmalloc(size); |
out = (uint8 *) xmalloc(size); |
974 |
XFree(sizehints); |
XFree(sizehints); |
975 |
} |
} |
976 |
|
|
977 |
if ( g_embed_wnd ) |
if (g_embed_wnd) |
978 |
{ |
{ |
979 |
XReparentWindow(g_display, g_wnd, (Window)g_embed_wnd, 0, 0); |
XReparentWindow(g_display, g_wnd, (Window) g_embed_wnd, 0, 0); |
980 |
} |
} |
981 |
|
|
982 |
input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | |
input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | |
983 |
VisibilityChangeMask | FocusChangeMask; |
VisibilityChangeMask | FocusChangeMask; |
1010 |
XMaskEvent(g_display, VisibilityChangeMask, &xevent); |
XMaskEvent(g_display, VisibilityChangeMask, &xevent); |
1011 |
} |
} |
1012 |
while (xevent.type != VisibilityNotify); |
while (xevent.type != VisibilityNotify); |
1013 |
|
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; |
1014 |
|
|
1015 |
g_focused = False; |
g_focused = False; |
1016 |
g_mouse_in_wnd = False; |
g_mouse_in_wnd = False; |
1028 |
} |
} |
1029 |
|
|
1030 |
void |
void |
1031 |
|
ui_resize_window() |
1032 |
|
{ |
1033 |
|
XSizeHints *sizehints; |
1034 |
|
|
1035 |
|
sizehints = XAllocSizeHints(); |
1036 |
|
if (sizehints) |
1037 |
|
{ |
1038 |
|
sizehints->flags = PMinSize | PMaxSize; |
1039 |
|
sizehints->min_width = sizehints->max_width = g_width; |
1040 |
|
sizehints->min_height = sizehints->max_height = g_height; |
1041 |
|
XSetWMNormalHints(g_display, g_wnd, sizehints); |
1042 |
|
XFree(sizehints); |
1043 |
|
} |
1044 |
|
|
1045 |
|
if (!(g_fullscreen || g_embed_wnd)) |
1046 |
|
{ |
1047 |
|
XResizeWindow(g_display, g_wnd, g_width, g_height); |
1048 |
|
} |
1049 |
|
} |
1050 |
|
|
1051 |
|
void |
1052 |
ui_destroy_window(void) |
ui_destroy_window(void) |
1053 |
{ |
{ |
1054 |
if (g_IC != NULL) |
if (g_IC != NULL) |
1109 |
|
|
1110 |
switch (xevent.type) |
switch (xevent.type) |
1111 |
{ |
{ |
1112 |
|
case VisibilityNotify: |
1113 |
|
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; |
1114 |
|
break; |
1115 |
case ClientMessage: |
case ClientMessage: |
1116 |
/* the window manager told us to quit */ |
/* the window manager told us to quit */ |
1117 |
if ((xevent.xclient.message_type == g_protocol_atom) |
if ((xevent.xclient.message_type == g_protocol_atom) |
1808 |
{ |
{ |
1809 |
case 0: /* Solid */ |
case 0: /* Solid */ |
1810 |
SET_FOREGROUND(fgcolour); |
SET_FOREGROUND(fgcolour); |
1811 |
FILL_RECTANGLE(x, y, cx, cy); |
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
1812 |
break; |
break; |
1813 |
|
|
1814 |
case 2: /* Hatch */ |
case 2: /* Hatch */ |
1819 |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
1820 |
XSetStipple(g_display, g_gc, fill); |
XSetStipple(g_display, g_gc, fill); |
1821 |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
1822 |
FILL_RECTANGLE(x, y, cx, cy); |
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
1823 |
XSetFillStyle(g_display, g_gc, FillSolid); |
XSetFillStyle(g_display, g_gc, FillSolid); |
1824 |
XSetTSOrigin(g_display, g_gc, 0, 0); |
XSetTSOrigin(g_display, g_gc, 0, 0); |
1825 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((HGLYPH) fill); |
1829 |
for (i = 0; i != 8; i++) |
for (i = 0; i != 8; i++) |
1830 |
ipattern[7 - i] = brush->pattern[i]; |
ipattern[7 - i] = brush->pattern[i]; |
1831 |
fill = (Pixmap) ui_create_glyph(8, 8, ipattern); |
fill = (Pixmap) ui_create_glyph(8, 8, ipattern); |
|
|
|
1832 |
SET_FOREGROUND(bgcolour); |
SET_FOREGROUND(bgcolour); |
1833 |
SET_BACKGROUND(fgcolour); |
SET_BACKGROUND(fgcolour); |
1834 |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
1835 |
XSetStipple(g_display, g_gc, fill); |
XSetStipple(g_display, g_gc, fill); |
1836 |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
1837 |
|
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
|
FILL_RECTANGLE(x, y, cx, cy); |
|
|
|
|
1838 |
XSetFillStyle(g_display, g_gc, FillSolid); |
XSetFillStyle(g_display, g_gc, FillSolid); |
1839 |
XSetTSOrigin(g_display, g_gc, 0, 0); |
XSetTSOrigin(g_display, g_gc, 0, 0); |
1840 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((HGLYPH) fill); |
1845 |
} |
} |
1846 |
|
|
1847 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
1848 |
|
|
1849 |
|
if (g_ownbackstore) |
1850 |
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); |
1851 |
} |
} |
1852 |
|
|
1853 |
void |
void |
1858 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
1859 |
if (g_ownbackstore) |
if (g_ownbackstore) |
1860 |
{ |
{ |
1861 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
if (g_Unobscured) |
1862 |
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, y); |
{ |
1863 |
|
XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
1864 |
|
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, |
1865 |
|
y); |
1866 |
|
} |
1867 |
|
else |
1868 |
|
{ |
1869 |
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
1870 |
|
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, |
1871 |
|
y); |
1872 |
|
} |
1873 |
} |
} |
1874 |
else |
else |
1875 |
{ |
{ |