25 |
#define XK_MISCELLANY |
#define XK_MISCELLANY |
26 |
#include <X11/keysymdef.h> |
#include <X11/keysymdef.h> |
27 |
#include "rdesktop.h" |
#include "rdesktop.h" |
28 |
|
#include "scancodes.h" |
29 |
|
|
30 |
extern int width; |
extern int width; |
31 |
extern int height; |
extern int height; |
32 |
extern BOOL sendmotion; |
extern BOOL sendmotion; |
33 |
extern BOOL fullscreen; |
extern BOOL fullscreen; |
34 |
|
extern BOOL grab_keyboard; |
35 |
|
|
36 |
Display *display = NULL; |
Display *display = NULL; |
37 |
static int x_socket; |
static int x_socket; |
64 |
static XIM IM = NULL; |
static XIM IM = NULL; |
65 |
static XIC IC = NULL; |
static XIC IC = NULL; |
66 |
|
|
67 |
|
/* Compose support */ |
68 |
|
BOOL enable_compose = False; |
69 |
|
|
70 |
#define TRANSLATE(col) ( owncolmap ? col : translate_colour(colmap[col]) ) |
#define TRANSLATE(col) ( owncolmap ? col : translate_colour(colmap[col]) ) |
71 |
#define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col)); |
#define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col)); |
72 |
#define SET_BACKGROUND(col) XSetBackground(display, gc, TRANSLATE(col)); |
#define SET_BACKGROUND(col) XSetBackground(display, gc, TRANSLATE(col)); |
190 |
static unsigned long |
static unsigned long |
191 |
init_inputmethod(void) |
init_inputmethod(void) |
192 |
{ |
{ |
193 |
unsigned long filtered_events; |
unsigned long filtered_events = 0; |
194 |
|
|
195 |
IM = XOpenIM(display, NULL, NULL, NULL); |
IM = XOpenIM(display, NULL, NULL, NULL); |
196 |
if (IM == NULL) |
if (IM == NULL) |
241 |
} |
} |
242 |
} |
} |
243 |
|
|
244 |
|
BOOL |
245 |
|
ui_init() |
246 |
|
{ |
247 |
|
Screen *screen; |
248 |
|
display = XOpenDisplay(NULL); |
249 |
|
if (display == NULL) |
250 |
|
{ |
251 |
|
error("Failed to open display\n"); |
252 |
|
return False; |
253 |
|
} |
254 |
|
if(fullscreen) |
255 |
|
{ |
256 |
|
screen = DefaultScreenOfDisplay(display); |
257 |
|
width = WidthOfScreen(screen); |
258 |
|
height = HeightOfScreen(screen); |
259 |
|
} |
260 |
|
return True; |
261 |
|
} |
262 |
|
|
263 |
BOOL |
BOOL |
264 |
ui_create_window(char *title) |
ui_create_window(char *title) |
271 |
Screen *screen; |
Screen *screen; |
272 |
uint16 test; |
uint16 test; |
273 |
int i; |
int i; |
|
unsigned long filtered_events; |
|
|
|
|
|
display = XOpenDisplay(NULL); |
|
|
|
|
|
if (display == NULL) |
|
|
{ |
|
|
error("Failed to open display\n"); |
|
|
return False; |
|
|
} |
|
274 |
|
|
275 |
x_socket = ConnectionNumber(display); |
x_socket = ConnectionNumber(display); |
276 |
screen = DefaultScreenOfDisplay(display); |
screen = DefaultScreenOfDisplay(display); |
359 |
|
|
360 |
input_mask = |
input_mask = |
361 |
KeyPressMask | KeyReleaseMask | ButtonPressMask | |
KeyPressMask | KeyReleaseMask | ButtonPressMask | |
362 |
ButtonReleaseMask | EnterWindowMask | LeaveWindowMask; |
ButtonReleaseMask; |
363 |
|
if (grab_keyboard) |
364 |
|
input_mask |= EnterWindowMask | LeaveWindowMask; |
365 |
if (sendmotion) |
if (sendmotion) |
366 |
input_mask |= PointerMotionMask; |
input_mask |= PointerMotionMask; |
367 |
|
|
368 |
if (ownbackstore) |
if (ownbackstore) |
369 |
input_mask |= ExposureMask; |
input_mask |= ExposureMask; |
370 |
|
|
371 |
filtered_events = init_inputmethod(); |
if (enable_compose) |
372 |
|
input_mask |= init_inputmethod(); |
373 |
|
|
374 |
XSelectInput(display, wnd, input_mask | filtered_events); |
XSelectInput(display, wnd, input_mask); |
375 |
|
|
376 |
gc = XCreateGC(display, wnd, 0, NULL); |
gc = XCreateGC(display, wnd, 0, NULL); |
377 |
|
|
422 |
|
|
423 |
while (XCheckMaskEvent(display, ~0, &xevent)) |
while (XCheckMaskEvent(display, ~0, &xevent)) |
424 |
{ |
{ |
425 |
if (XFilterEvent(&xevent, None) == True) |
if (enable_compose && (XFilterEvent(&xevent, None) == True)) |
426 |
{ |
{ |
427 |
DEBUG_KBD("Filtering event\n"); |
DEBUG_KBD("Filtering event\n"); |
428 |
continue; |
continue; |
473 |
|
|
474 |
tr = xkeymap_translate_key(keysym, |
tr = xkeymap_translate_key(keysym, |
475 |
xevent.xkey. |
xevent.xkey. |
476 |
keycode); |
keycode, |
477 |
|
xevent.xkey.state); |
478 |
|
|
479 |
ensure_remote_modifiers(ev_time, tr); |
ensure_remote_modifiers(ev_time, tr); |
480 |
|
|
481 |
if (tr.scancode == 0) |
if (tr.scancode == 0) |
498 |
|
|
499 |
tr = xkeymap_translate_key(keysym, |
tr = xkeymap_translate_key(keysym, |
500 |
xevent.xkey. |
xevent.xkey. |
501 |
keycode); |
keycode, |
502 |
|
xevent.xkey.state); |
503 |
|
|
504 |
if (tr.scancode == 0) |
if (tr.scancode == 0) |
505 |
break; |
break; |
532 |
xevent.xmotion.y); |
xevent.xmotion.y); |
533 |
break; |
break; |
534 |
|
|
535 |
|
case FocusIn: |
536 |
|
/* fall through */ |
537 |
case EnterNotify: |
case EnterNotify: |
538 |
XGrabKeyboard(display, wnd, True, |
if (grab_keyboard) |
539 |
GrabModeAsync, GrabModeAsync, |
XGrabKeyboard(display, wnd, True, |
540 |
CurrentTime); |
GrabModeAsync, |
541 |
|
GrabModeAsync, |
542 |
|
CurrentTime); |
543 |
break; |
break; |
544 |
|
|
545 |
|
case FocusOut: |
546 |
|
/* reset keys */ |
547 |
|
rdp_send_input(ev_time, RDP_INPUT_SCANCODE, |
548 |
|
KBD_FLAG_DOWN | KBD_FLAG_UP, |
549 |
|
SCANCODE_CHAR_LCTRL, 0); |
550 |
|
rdp_send_input(ev_time, RDP_INPUT_SCANCODE, |
551 |
|
KBD_FLAG_DOWN | KBD_FLAG_UP, |
552 |
|
SCANCODE_CHAR_LALT, 0); |
553 |
|
/* fall through */ |
554 |
case LeaveNotify: |
case LeaveNotify: |
555 |
XUngrabKeyboard(display, CurrentTime); |
if (grab_keyboard) |
556 |
|
XUngrabKeyboard(display, CurrentTime); |
557 |
break; |
break; |
558 |
|
|
559 |
case Expose: |
case Expose: |
617 |
|
|
618 |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
619 |
bitmap = XCreatePixmap(display, wnd, width, height, depth); |
bitmap = XCreatePixmap(display, wnd, width, height, depth); |
620 |
image = XCreateImage(display, visual, depth, ZPixmap, 0, tdata, width, |
image = XCreateImage(display, visual, depth, ZPixmap, 0, |
621 |
height, 8, 0); |
(char *) tdata, width, height, 8, 0); |
622 |
|
|
623 |
XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height); |
XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height); |
624 |
|
|
636 |
uint8 *tdata; |
uint8 *tdata; |
637 |
|
|
638 |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
639 |
image = XCreateImage(display, visual, depth, ZPixmap, 0, tdata, width, |
image = XCreateImage(display, visual, depth, ZPixmap, 0, |
640 |
height, 8, 0); |
(char *) tdata, width, height, 8, 0); |
641 |
|
|
642 |
if (ownbackstore) |
if (ownbackstore) |
643 |
{ |
{ |
673 |
bitmap = XCreatePixmap(display, wnd, width, height, 1); |
bitmap = XCreatePixmap(display, wnd, width, height, 1); |
674 |
gc = XCreateGC(display, bitmap, 0, NULL); |
gc = XCreateGC(display, bitmap, 0, NULL); |
675 |
|
|
676 |
image = XCreateImage(display, visual, 1, ZPixmap, 0, data, width, |
image = XCreateImage(display, visual, 1, ZPixmap, 0, (char *) data, |
677 |
height, 8, scanline); |
width, height, 8, scanline); |
678 |
image->byte_order = MSBFirst; |
image->byte_order = MSBFirst; |
679 |
image->bitmap_bit_order = MSBFirst; |
image->bitmap_bit_order = MSBFirst; |
680 |
XInitImage(image); |
XInitImage(image); |
920 |
FILL_RECTANGLE(x, y, cx, cy); |
FILL_RECTANGLE(x, y, cx, cy); |
921 |
|
|
922 |
XSetFillStyle(display, gc, FillSolid); |
XSetFillStyle(display, gc, FillSolid); |
923 |
|
XSetTSOrigin(display, gc, 0, 0); |
924 |
ui_destroy_glyph((HGLYPH) fill); |
ui_destroy_glyph((HGLYPH) fill); |
925 |
break; |
break; |
926 |
|
|
1045 |
if ((xyoffset & 0x80))\ |
if ((xyoffset & 0x80))\ |
1046 |
{\ |
{\ |
1047 |
if (flags & TEXT2_VERTICAL) \ |
if (flags & TEXT2_VERTICAL) \ |
1048 |
y += ttext[++idx] | (ttext[++idx] << 8);\ |
y += ttext[idx+1] | (ttext[idx+2] << 8);\ |
1049 |
else\ |
else\ |
1050 |
x += ttext[++idx] | (ttext[++idx] << 8);\ |
x += ttext[idx+1] | (ttext[idx+2] << 8);\ |
1051 |
|
idx += 2;\ |
1052 |
}\ |
}\ |
1053 |
else\ |
else\ |
1054 |
{\ |
{\ |
1186 |
if (data == NULL) |
if (data == NULL) |
1187 |
return; |
return; |
1188 |
|
|
1189 |
image = XCreateImage(display, visual, depth, ZPixmap, 0, data, cx, cy, |
image = XCreateImage(display, visual, depth, ZPixmap, 0, |
1190 |
BitmapPad(display), cx * bpp / 8); |
(char *) data, cx, cy, BitmapPad(display), |
1191 |
|
cx * bpp / 8); |
1192 |
|
|
1193 |
if (ownbackstore) |
if (ownbackstore) |
1194 |
{ |
{ |