247 |
} |
} |
248 |
} |
} |
249 |
|
|
250 |
static BOOL |
BOOL |
251 |
get_key_state(int keysym) |
get_key_state(int keysym) |
252 |
{ |
{ |
253 |
int keysymMask = 0, modifierpos, key; |
int keysymMask = 0, modifierpos, key; |
517 |
XFreePixmap(display, pixmap); |
XFreePixmap(display, pixmap); |
518 |
} |
} |
519 |
|
|
520 |
|
/* Process all events in Xlib queue */ |
521 |
static void |
static void |
522 |
xwin_process_events() |
xwin_process_events() |
523 |
{ |
{ |
531 |
char str[256]; |
char str[256]; |
532 |
Status status; |
Status status; |
533 |
|
|
|
/* Refresh keyboard mapping if it has changed. This is important for |
|
|
Xvnc, since it allocates keycodes dynamically */ |
|
|
if (XCheckTypedEvent(display, MappingNotify, &xevent)) |
|
|
{ |
|
|
if (xevent.xmapping.request == MappingKeyboard |
|
|
|| xevent.xmapping.request == MappingModifier) |
|
|
XRefreshKeyboardMapping(&xevent.xmapping); |
|
|
} |
|
|
|
|
534 |
while (XCheckMaskEvent(display, ~0, &xevent)) |
while (XCheckMaskEvent(display, ~0, &xevent)) |
535 |
{ |
{ |
536 |
if (enable_compose && (XFilterEvent(&xevent, None) == True)) |
if (enable_compose && (XFilterEvent(&xevent, None) == True)) |
566 |
str, sizeof(str), &keysym, NULL); |
str, sizeof(str), &keysym, NULL); |
567 |
} |
} |
568 |
|
|
|
if (keysym == XK_Break) /* toggle full screen */ |
|
|
{ |
|
|
if (get_key_state(XK_Alt_L) || get_key_state(XK_Alt_R)) |
|
|
{ |
|
|
toggle_fullscreen(); |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
569 |
ksname = get_ksname(keysym); |
ksname = get_ksname(keysym); |
570 |
DEBUG_KBD(("\nKeyPress for (keysym 0x%lx, %s)\n", keysym, ksname)); |
DEBUG_KBD(("\nKeyPress for (keysym 0x%lx, %s)\n", keysym, ksname)); |
571 |
|
|
572 |
if (inhibit_key(keysym)) |
if (handle_special_keys(keysym, ev_time, True)) |
|
{ |
|
|
DEBUG_KBD(("Inhibiting key\n")); |
|
573 |
break; |
break; |
|
} |
|
574 |
|
|
575 |
tr = xkeymap_translate_key(keysym, |
tr = xkeymap_translate_key(keysym, |
576 |
xevent.xkey.keycode, xevent.xkey.state); |
xevent.xkey.keycode, xevent.xkey.state); |
577 |
|
|
|
ensure_remote_modifiers(ev_time, tr); |
|
|
|
|
578 |
if (tr.scancode == 0) |
if (tr.scancode == 0) |
579 |
break; |
break; |
580 |
|
|
581 |
|
ensure_remote_modifiers(ev_time, tr); |
582 |
|
|
583 |
rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode); |
rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode); |
584 |
break; |
break; |
585 |
case KeyRelease: |
case KeyRelease: |
590 |
DEBUG_KBD(("\nKeyRelease for (keysym 0x%lx, %s)\n", keysym, |
DEBUG_KBD(("\nKeyRelease for (keysym 0x%lx, %s)\n", keysym, |
591 |
ksname)); |
ksname)); |
592 |
|
|
593 |
if (inhibit_key(keysym)) |
if (handle_special_keys(keysym, ev_time, False)) |
594 |
break; |
break; |
595 |
|
|
596 |
tr = xkeymap_translate_key(keysym, |
tr = xkeymap_translate_key(keysym, |
643 |
xevent.xexpose.height, |
xevent.xexpose.height, |
644 |
xevent.xexpose.x, xevent.xexpose.y); |
xevent.xexpose.x, xevent.xexpose.y); |
645 |
break; |
break; |
646 |
|
|
647 |
|
case MappingNotify: |
648 |
|
/* Refresh keyboard mapping if it has changed. This is important for |
649 |
|
Xvnc, since it allocates keycodes dynamically */ |
650 |
|
if (xevent.xmapping.request == MappingKeyboard |
651 |
|
|| xevent.xmapping.request == MappingModifier) |
652 |
|
XRefreshKeyboardMapping(&xevent.xmapping); |
653 |
|
break; |
654 |
|
|
655 |
} |
} |
656 |
} |
} |
657 |
} |
} |
661 |
{ |
{ |
662 |
int n = (rdp_socket > x_socket) ? rdp_socket + 1 : x_socket + 1; |
int n = (rdp_socket > x_socket) ? rdp_socket + 1 : x_socket + 1; |
663 |
fd_set rfds; |
fd_set rfds; |
664 |
|
XEvent xevent; |
665 |
|
|
666 |
FD_ZERO(&rfds); |
FD_ZERO(&rfds); |
667 |
|
|
668 |
while (True) |
while (True) |
669 |
{ |
{ |
670 |
|
/* Process any events already in queue */ |
671 |
|
xwin_process_events(); |
672 |
|
|
673 |
FD_ZERO(&rfds); |
FD_ZERO(&rfds); |
674 |
FD_SET(rdp_socket, &rfds); |
FD_SET(rdp_socket, &rfds); |
675 |
if (display != NULL) |
if (display != NULL) |
688 |
} |
} |
689 |
|
|
690 |
if (FD_ISSET(x_socket, &rfds)) |
if (FD_ISSET(x_socket, &rfds)) |
691 |
xwin_process_events(); |
{ |
692 |
|
/* Move new events from socket to queue */ |
693 |
|
XPeekEvent(display, &xevent); |
694 |
|
continue; |
695 |
|
} |
696 |
|
|
697 |
if (FD_ISSET(rdp_socket, &rfds)) |
if (FD_ISSET(rdp_socket, &rfds)) |
698 |
return; |
return; |