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 |
|
|
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 |
|
) |
257 |
|
else if (g_xserver_be) |
258 |
{ |
{ |
259 |
while (out < end) |
while (out < end) |
260 |
{ |
{ |
307 |
{ |
{ |
308 |
uint32 value; |
uint32 value; |
309 |
|
|
310 |
if (g_xserver_be) |
if (g_arch_match) |
311 |
|
REPEAT(*(((uint32 *) out)++) = g_colmap[*(data++)]; |
312 |
|
) |
313 |
|
else if (g_xserver_be) |
314 |
{ |
{ |
315 |
while (out < end) |
while (out < end) |
316 |
{ |
{ |
621 |
/* if server and xserver bpp match, */ |
/* if server and xserver bpp match, */ |
622 |
/* and arch(endian) matches, no need to translate */ |
/* and arch(endian) matches, no need to translate */ |
623 |
/* just return data */ |
/* just return data */ |
624 |
if (g_depth > 8) |
if (g_arch_match) |
625 |
if (g_arch_match) |
{ |
626 |
if (g_depth == g_server_bpp) |
if (g_depth == 15 && g_server_bpp == 15) |
627 |
return data; |
return data; |
628 |
|
if (g_depth == 16 && g_server_bpp == 16) |
629 |
|
return data; |
630 |
|
} |
631 |
|
|
632 |
size = width * height * (g_bpp / 8); |
size = width * height * (g_bpp / 8); |
633 |
out = (uint8 *) xmalloc(size); |
out = (uint8 *) xmalloc(size); |
972 |
XFree(sizehints); |
XFree(sizehints); |
973 |
} |
} |
974 |
|
|
975 |
if ( g_embed_wnd ) |
if (g_embed_wnd) |
976 |
{ |
{ |
977 |
XReparentWindow(g_display, g_wnd, (Window)g_embed_wnd, 0, 0); |
XReparentWindow(g_display, g_wnd, (Window) g_embed_wnd, 0, 0); |
978 |
} |
} |
979 |
|
|
980 |
input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | |
input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | |
981 |
VisibilityChangeMask | FocusChangeMask; |
VisibilityChangeMask | FocusChangeMask; |
1008 |
XMaskEvent(g_display, VisibilityChangeMask, &xevent); |
XMaskEvent(g_display, VisibilityChangeMask, &xevent); |
1009 |
} |
} |
1010 |
while (xevent.type != VisibilityNotify); |
while (xevent.type != VisibilityNotify); |
1011 |
|
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; |
1012 |
|
|
1013 |
g_focused = False; |
g_focused = False; |
1014 |
g_mouse_in_wnd = False; |
g_mouse_in_wnd = False; |
1026 |
} |
} |
1027 |
|
|
1028 |
void |
void |
1029 |
|
ui_resize_window() |
1030 |
|
{ |
1031 |
|
XSizeHints *sizehints; |
1032 |
|
|
1033 |
|
sizehints = XAllocSizeHints(); |
1034 |
|
if (sizehints) |
1035 |
|
{ |
1036 |
|
sizehints->flags = PMinSize | PMaxSize; |
1037 |
|
sizehints->min_width = sizehints->max_width = g_width; |
1038 |
|
sizehints->min_height = sizehints->max_height = g_height; |
1039 |
|
XSetWMNormalHints(g_display, g_wnd, sizehints); |
1040 |
|
XFree(sizehints); |
1041 |
|
} |
1042 |
|
|
1043 |
|
if (!(g_fullscreen || g_embed_wnd)) |
1044 |
|
{ |
1045 |
|
XResizeWindow(g_display, g_wnd, g_width, g_height); |
1046 |
|
} |
1047 |
|
} |
1048 |
|
|
1049 |
|
void |
1050 |
ui_destroy_window(void) |
ui_destroy_window(void) |
1051 |
{ |
{ |
1052 |
if (g_IC != NULL) |
if (g_IC != NULL) |
1107 |
|
|
1108 |
switch (xevent.type) |
switch (xevent.type) |
1109 |
{ |
{ |
1110 |
|
case VisibilityNotify: |
1111 |
|
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured; |
1112 |
|
break; |
1113 |
case ClientMessage: |
case ClientMessage: |
1114 |
/* the window manager told us to quit */ |
/* the window manager told us to quit */ |
1115 |
if ((xevent.xclient.message_type == g_protocol_atom) |
if ((xevent.xclient.message_type == g_protocol_atom) |
1806 |
{ |
{ |
1807 |
case 0: /* Solid */ |
case 0: /* Solid */ |
1808 |
SET_FOREGROUND(fgcolour); |
SET_FOREGROUND(fgcolour); |
1809 |
FILL_RECTANGLE(x, y, cx, cy); |
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
1810 |
break; |
break; |
1811 |
|
|
1812 |
case 2: /* Hatch */ |
case 2: /* Hatch */ |
1817 |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
1818 |
XSetStipple(g_display, g_gc, fill); |
XSetStipple(g_display, g_gc, fill); |
1819 |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
1820 |
FILL_RECTANGLE(x, y, cx, cy); |
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
1821 |
XSetFillStyle(g_display, g_gc, FillSolid); |
XSetFillStyle(g_display, g_gc, FillSolid); |
1822 |
XSetTSOrigin(g_display, g_gc, 0, 0); |
XSetTSOrigin(g_display, g_gc, 0, 0); |
1823 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((HGLYPH) fill); |
1827 |
for (i = 0; i != 8; i++) |
for (i = 0; i != 8; i++) |
1828 |
ipattern[7 - i] = brush->pattern[i]; |
ipattern[7 - i] = brush->pattern[i]; |
1829 |
fill = (Pixmap) ui_create_glyph(8, 8, ipattern); |
fill = (Pixmap) ui_create_glyph(8, 8, ipattern); |
|
|
|
1830 |
SET_FOREGROUND(bgcolour); |
SET_FOREGROUND(bgcolour); |
1831 |
SET_BACKGROUND(fgcolour); |
SET_BACKGROUND(fgcolour); |
1832 |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
XSetFillStyle(g_display, g_gc, FillOpaqueStippled); |
1833 |
XSetStipple(g_display, g_gc, fill); |
XSetStipple(g_display, g_gc, fill); |
1834 |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin); |
1835 |
|
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy); |
|
FILL_RECTANGLE(x, y, cx, cy); |
|
|
|
|
1836 |
XSetFillStyle(g_display, g_gc, FillSolid); |
XSetFillStyle(g_display, g_gc, FillSolid); |
1837 |
XSetTSOrigin(g_display, g_gc, 0, 0); |
XSetTSOrigin(g_display, g_gc, 0, 0); |
1838 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((HGLYPH) fill); |
1843 |
} |
} |
1844 |
|
|
1845 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
1846 |
|
|
1847 |
|
if (g_ownbackstore) |
1848 |
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); |
1849 |
} |
} |
1850 |
|
|
1851 |
void |
void |
1856 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
1857 |
if (g_ownbackstore) |
if (g_ownbackstore) |
1858 |
{ |
{ |
1859 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
if (g_Unobscured) |
1860 |
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, y); |
{ |
1861 |
|
XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
1862 |
|
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, |
1863 |
|
y); |
1864 |
|
} |
1865 |
|
else |
1866 |
|
{ |
1867 |
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
1868 |
|
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, |
1869 |
|
y); |
1870 |
|
} |
1871 |
} |
} |
1872 |
else |
else |
1873 |
{ |
{ |