21 |
#include <X11/Xlib.h> |
#include <X11/Xlib.h> |
22 |
#include <X11/Xutil.h> |
#include <X11/Xutil.h> |
23 |
#include <unistd.h> |
#include <unistd.h> |
24 |
|
#include <sys/time.h> |
25 |
#include <time.h> |
#include <time.h> |
26 |
#include <errno.h> |
#include <errno.h> |
27 |
|
#include <strings.h> |
28 |
#include "rdesktop.h" |
#include "rdesktop.h" |
29 |
#include "xproto.h" |
#include "xproto.h" |
30 |
|
|
64 |
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; |
65 |
|
|
66 |
/* software backing store */ |
/* software backing store */ |
67 |
static BOOL g_ownbackstore; |
BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ |
68 |
static Pixmap g_backstore = NULL; |
static Pixmap g_backstore = 0; |
69 |
|
|
70 |
/* Moving in single app mode */ |
/* Moving in single app mode */ |
71 |
static BOOL g_moving_wnd; |
static BOOL g_moving_wnd; |
169 |
split_colour15(uint32 colour) |
split_colour15(uint32 colour) |
170 |
{ |
{ |
171 |
PixelColour rv; |
PixelColour rv; |
172 |
rv.red = (colour & 0x7c00) >> 10; |
rv.red = (colour & 0x7c00) >> 7; |
173 |
rv.red = (rv.red * 0xff) / 0x1f; |
rv.green = (colour & 0x03e0) >> 2; |
174 |
rv.green = (colour & 0x03e0) >> 5; |
rv.blue = (colour & 0x001f) << 3; |
|
rv.green = (rv.green * 0xff) / 0x1f; |
|
|
rv.blue = (colour & 0x1f); |
|
|
rv.blue = (rv.blue * 0xff) / 0x1f; |
|
175 |
return rv; |
return rv; |
176 |
} |
} |
177 |
|
|
179 |
split_colour16(uint32 colour) |
split_colour16(uint32 colour) |
180 |
{ |
{ |
181 |
PixelColour rv; |
PixelColour rv; |
182 |
rv.red = (colour & 0xf800) >> 11; |
rv.red = (colour & 0xf800) >> 8; |
183 |
rv.red = (rv.red * 0xff) / 0x1f; |
rv.green = (colour & 0x07e0) >> 3; |
184 |
rv.green = (colour & 0x07e0) >> 5; |
rv.blue = (colour & 0x001f) << 3; |
|
rv.green = (rv.green * 0xff) / 0x3f; |
|
|
rv.blue = (colour & 0x001f); |
|
|
rv.blue = (rv.blue * 0xff) / 0x1f; |
|
185 |
return rv; |
return rv; |
186 |
} |
} |
187 |
|
|
189 |
split_colour24(uint32 colour) |
split_colour24(uint32 colour) |
190 |
{ |
{ |
191 |
PixelColour rv; |
PixelColour rv; |
192 |
rv.blue = (colour & 0xff0000) >> 16; |
rv.blue = (colour & 0xff0000) >> 16; |
193 |
rv.green = (colour & 0xff00) >> 8; |
rv.green = (colour & 0x00ff00) >> 8; |
194 |
rv.red = (colour & 0xff); |
rv.red = (colour & 0x0000ff); |
195 |
return rv; |
return rv; |
196 |
} |
} |
197 |
|
|
786 |
warning("Screen depth is 8 bits or lower: you may want to use -C for a private colourmap\n"); |
warning("Screen depth is 8 bits or lower: you may want to use -C for a private colourmap\n"); |
787 |
} |
} |
788 |
|
|
789 |
if (DoesBackingStore(g_screen) != Always) |
if ((!g_ownbackstore) && (DoesBackingStore(g_screen) != Always)) |
790 |
|
{ |
791 |
|
warning("External BackingStore not available, using internal\n"); |
792 |
g_ownbackstore = True; |
g_ownbackstore = True; |
793 |
|
} |
794 |
|
|
795 |
test = 1; |
test = 1; |
796 |
g_host_be = !(BOOL) (*(uint8 *) (&test)); |
g_host_be = !(BOOL) (*(uint8 *) (&test)); |
893 |
if (g_gc == NULL) |
if (g_gc == NULL) |
894 |
g_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
g_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
895 |
|
|
896 |
if ((g_ownbackstore) && (g_backstore == NULL)) |
if ((g_ownbackstore) && (g_backstore == 0)) |
897 |
{ |
{ |
898 |
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); |
899 |
|
|
1270 |
int |
int |
1271 |
ui_select(int rdp_socket) |
ui_select(int rdp_socket) |
1272 |
{ |
{ |
1273 |
int n = (rdp_socket > g_x_socket) ? rdp_socket + 1 : g_x_socket + 1; |
int n; |
1274 |
fd_set rfds, wfds; |
fd_set rfds, wfds; |
1275 |
|
struct timeval tv; |
1276 |
|
BOOL s_timeout = False; |
1277 |
|
|
1278 |
while (True) |
while (True) |
1279 |
{ |
{ |
1280 |
|
n = (rdp_socket > g_x_socket) ? rdp_socket : g_x_socket; |
1281 |
/* Process any events already waiting */ |
/* Process any events already waiting */ |
1282 |
if (!xwin_process_events()) |
if (!xwin_process_events()) |
1283 |
/* User quit */ |
/* User quit */ |
1293 |
if (g_dsp_busy) |
if (g_dsp_busy) |
1294 |
{ |
{ |
1295 |
FD_SET(g_dsp_fd, &wfds); |
FD_SET(g_dsp_fd, &wfds); |
1296 |
n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n; |
n = (g_dsp_fd > n) ? g_dsp_fd : n; |
1297 |
} |
} |
1298 |
#endif |
#endif |
1299 |
|
/* default timeout */ |
1300 |
|
tv.tv_sec = 60; |
1301 |
|
tv.tv_usec = 0; |
1302 |
|
|
1303 |
|
/* add redirection handles */ |
1304 |
|
rdpdr_add_fds(&n, &rfds, &wfds, &tv, &s_timeout); |
1305 |
|
|
1306 |
switch (select(n, &rfds, &wfds, NULL, NULL)) |
n++; |
1307 |
|
|
1308 |
|
switch (select(n, &rfds, &wfds, NULL, &tv)) |
1309 |
{ |
{ |
1310 |
case -1: |
case -1: |
1311 |
error("select: %s\n", strerror(errno)); |
error("select: %s\n", strerror(errno)); |
1312 |
|
|
1313 |
case 0: |
case 0: |
1314 |
|
/* TODO: if tv.tv_sec just times out |
1315 |
|
* we will segfault. |
1316 |
|
* FIXME: |
1317 |
|
*/ |
1318 |
|
//s_timeout = True; |
1319 |
|
//rdpdr_check_fds(&rfds, &wfds, (BOOL) True); |
1320 |
continue; |
continue; |
1321 |
} |
} |
1322 |
|
|
1323 |
|
rdpdr_check_fds(&rfds, &wfds, (BOOL) False); |
1324 |
|
|
1325 |
if (FD_ISSET(rdp_socket, &rfds)) |
if (FD_ISSET(rdp_socket, &rfds)) |
1326 |
return 1; |
return 1; |
1327 |
|
|
1777 |
/* src */ int srcx, int srcy) |
/* src */ int srcx, int srcy) |
1778 |
{ |
{ |
1779 |
SET_FUNCTION(opcode); |
SET_FUNCTION(opcode); |
|
XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
|
1780 |
if (g_ownbackstore) |
if (g_ownbackstore) |
1781 |
|
{ |
1782 |
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
1783 |
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, y); |
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, y); |
1784 |
|
} |
1785 |
|
else |
1786 |
|
{ |
1787 |
|
XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y); |
1788 |
|
} |
1789 |
RESET_FUNCTION(opcode); |
RESET_FUNCTION(opcode); |
1790 |
} |
} |
1791 |
|
|