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 |
static GC g_gc = NULL; |
static GC g_gc = NULL; |
49 |
static Visual *g_visual; |
static Visual *g_visual; |
57 |
static Atom g_protocol_atom, g_kill_atom; |
static Atom g_protocol_atom, g_kill_atom; |
58 |
static BOOL g_focused; |
static BOOL g_focused; |
59 |
static BOOL g_mouse_in_wnd; |
static BOOL g_mouse_in_wnd; |
60 |
|
static BOOL g_arch_match = False; /* set to True if RGB XServer and little endian */ |
61 |
|
|
62 |
/* endianness */ |
/* endianness */ |
63 |
static BOOL g_host_be; |
static BOOL g_host_be; |
66 |
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; |
67 |
|
|
68 |
/* software backing store */ |
/* software backing store */ |
69 |
BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ |
extern BOOL g_ownbackstore; |
70 |
static Pixmap g_backstore = 0; |
static Pixmap g_backstore = 0; |
71 |
|
|
72 |
/* Moving in single app mode */ |
/* Moving in single app mode */ |
115 |
} |
} |
116 |
|
|
117 |
/* colour maps */ |
/* colour maps */ |
118 |
BOOL g_owncolmap = False; |
extern BOOL g_owncolmap; |
119 |
static Colormap g_xcolmap; |
static Colormap g_xcolmap; |
120 |
static uint32 *g_colmap = NULL; |
static uint32 *g_colmap = NULL; |
121 |
|
|
598 |
static uint8 * |
static uint8 * |
599 |
translate_image(int width, int height, uint8 * data) |
translate_image(int width, int height, uint8 * data) |
600 |
{ |
{ |
601 |
int size = width * height * g_bpp / 8; |
int size; |
602 |
uint8 *out = (uint8 *) xmalloc(size); |
uint8 *out; |
603 |
uint8 *end = out + size; |
uint8 *end; |
604 |
|
|
605 |
|
/* if server and xserver bpp match, */ |
606 |
|
/* and arch(endian) matches, no need to translate */ |
607 |
|
/* just return data */ |
608 |
|
if (g_arch_match) |
609 |
|
{ |
610 |
|
if (g_depth == 15 && g_server_bpp == 15) |
611 |
|
return data; |
612 |
|
if (g_depth == 16 && g_server_bpp == 16) |
613 |
|
return data; |
614 |
|
} |
615 |
|
|
616 |
|
size = width * height * (g_bpp / 8); |
617 |
|
out = (uint8 *) xmalloc(size); |
618 |
|
end = out + size; |
619 |
|
|
620 |
switch (g_server_bpp) |
switch (g_server_bpp) |
621 |
{ |
{ |
753 |
TrueColorVisual = True; |
TrueColorVisual = True; |
754 |
} |
} |
755 |
|
|
756 |
|
test = 1; |
757 |
|
g_host_be = !(BOOL) (*(uint8 *) (&test)); |
758 |
|
g_xserver_be = (ImageByteOrder(g_display) == MSBFirst); |
759 |
|
|
760 |
if ((g_server_bpp == 8) && ((!TrueColorVisual) || (g_depth <= 8))) |
if ((g_server_bpp == 8) && ((!TrueColorVisual) || (g_depth <= 8))) |
761 |
{ |
{ |
762 |
/* we use a colourmap, so the default visual should do */ |
/* we use a colourmap, so the default visual should do */ |
783 |
calculate_shifts(vi.red_mask, &g_red_shift_r, &g_red_shift_l); |
calculate_shifts(vi.red_mask, &g_red_shift_r, &g_red_shift_l); |
784 |
calculate_shifts(vi.blue_mask, &g_blue_shift_r, &g_blue_shift_l); |
calculate_shifts(vi.blue_mask, &g_blue_shift_r, &g_blue_shift_l); |
785 |
calculate_shifts(vi.green_mask, &g_green_shift_r, &g_green_shift_l); |
calculate_shifts(vi.green_mask, &g_green_shift_r, &g_green_shift_l); |
786 |
|
|
787 |
|
/* if RGB video and averything is little endian */ |
788 |
|
if (vi.red_mask > vi.green_mask && vi.green_mask > vi.blue_mask) |
789 |
|
if (!g_xserver_be && !g_host_be) |
790 |
|
g_arch_match = True; |
791 |
} |
} |
792 |
|
|
793 |
pfm = XListPixmapFormats(g_display, &i); |
pfm = XListPixmapFormats(g_display, &i); |
827 |
g_ownbackstore = True; |
g_ownbackstore = True; |
828 |
} |
} |
829 |
|
|
|
test = 1; |
|
|
g_host_be = !(BOOL) (*(uint8 *) (&test)); |
|
|
g_xserver_be = (ImageByteOrder(g_display) == MSBFirst); |
|
|
|
|
830 |
/* |
/* |
831 |
* Determine desktop size |
* Determine desktop size |
832 |
*/ |
*/ |
956 |
XFree(sizehints); |
XFree(sizehints); |
957 |
} |
} |
958 |
|
|
959 |
if ( g_embed_wnd ) |
if (g_embed_wnd) |
960 |
{ |
{ |
961 |
XReparentWindow(g_display, g_wnd, (Window)g_embed_wnd, 0, 0); |
XReparentWindow(g_display, g_wnd, (Window) g_embed_wnd, 0, 0); |
962 |
} |
} |
963 |
|
|
964 |
input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | |
input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | |
965 |
VisibilityChangeMask | FocusChangeMask; |
VisibilityChangeMask | FocusChangeMask; |
1009 |
} |
} |
1010 |
|
|
1011 |
void |
void |
1012 |
|
ui_resize_window() |
1013 |
|
{ |
1014 |
|
XSizeHints *sizehints; |
1015 |
|
|
1016 |
|
sizehints = XAllocSizeHints(); |
1017 |
|
if (sizehints) |
1018 |
|
{ |
1019 |
|
sizehints->flags = PMinSize | PMaxSize; |
1020 |
|
sizehints->min_width = sizehints->max_width = g_width; |
1021 |
|
sizehints->min_height = sizehints->max_height = g_height; |
1022 |
|
XSetWMNormalHints(g_display, g_wnd, sizehints); |
1023 |
|
XFree(sizehints); |
1024 |
|
} |
1025 |
|
|
1026 |
|
if (!(g_fullscreen || g_embed_wnd)) |
1027 |
|
{ |
1028 |
|
XResizeWindow(g_display, g_wnd, g_width, g_height); |
1029 |
|
} |
1030 |
|
} |
1031 |
|
|
1032 |
|
void |
1033 |
ui_destroy_window(void) |
ui_destroy_window(void) |
1034 |
{ |
{ |
1035 |
if (g_IC != NULL) |
if (g_IC != NULL) |
1423 |
XPutImage(g_display, bitmap, g_gc, image, 0, 0, 0, 0, width, height); |
XPutImage(g_display, bitmap, g_gc, image, 0, 0, 0, 0, width, height); |
1424 |
|
|
1425 |
XFree(image); |
XFree(image); |
1426 |
if (!g_owncolmap) |
if (tdata != data) |
1427 |
xfree(tdata); |
xfree(tdata); |
1428 |
return (HBITMAP) bitmap; |
return (HBITMAP) bitmap; |
1429 |
} |
} |
1462 |
} |
} |
1463 |
|
|
1464 |
XFree(image); |
XFree(image); |
1465 |
if (!g_owncolmap) |
if (tdata != data) |
1466 |
xfree(tdata); |
xfree(tdata); |
1467 |
} |
} |
1468 |
|
|