Changeset 99441 in vbox
- Timestamp:
- Apr 18, 2023 12:04:47 PM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
r99438 r99441 820 820 821 821 # elif defined(VBOX_WS_X11) 822 823 /* Cast to XCB event: */ 824 xcb_generic_event_t *pEvent = static_cast<xcb_generic_event_t*>(pMessage); 825 826 /* Depending on event type: */ 827 switch (pEvent->response_type & ~0x80) 828 { 829 /* Watch for key-events: */ 830 case XCB_KEY_PRESS: 831 case XCB_KEY_RELEASE: 832 { 833 /* Cast to XCB key-event: */ 834 xcb_key_press_event_t *pKeyEvent = static_cast<xcb_key_press_event_t*>(pMessage); 835 836 /* Translate the keycode to a PC scan code: */ 837 unsigned uScan = handleXKeyEvent(NativeWindowSubsystem::X11GetDisplay(), pKeyEvent->detail); 838 839 /* Scan codes 0x00 (no valid translation) and 0x80 (extended flag) are ignored: */ 840 if (!(uScan & 0x7F)) 841 { 842 fResult = true; 843 break; 844 } 845 846 /* Calculate flags: */ 847 int iflags = 0; 848 if (uScan >> 8) 849 iflags |= KeyExtended; 850 if ((pEvent->response_type & ~0x80) == XCB_KEY_PRESS) 851 iflags |= KeyPressed; 852 853 /* Remove the extended flag: */ 854 uScan &= 0x7F; 855 856 /* Special Korean keys must send scan code 0xF1/0xF2 857 * when pressed and nothing when released. */ 858 if (uScan == 0x71 || uScan == 0x72) 859 { 860 if ((pEvent->response_type & ~0x80) == XCB_KEY_RELEASE) 822 if (uiCommon().X11ServerAvailable()) 823 { 824 /* Cast to XCB event: */ 825 xcb_generic_event_t *pEvent = static_cast<xcb_generic_event_t*>(pMessage); 826 827 /* Depending on event type: */ 828 switch (pEvent->response_type & ~0x80) 829 { 830 /* Watch for key-events: */ 831 case XCB_KEY_PRESS: 832 case XCB_KEY_RELEASE: 833 { 834 /* Cast to XCB key-event: */ 835 xcb_key_press_event_t *pKeyEvent = static_cast<xcb_key_press_event_t*>(pMessage); 836 837 /* Translate the keycode to a PC scan code: */ 838 unsigned uScan = handleXKeyEvent(NativeWindowSubsystem::X11GetDisplay(), pKeyEvent->detail); 839 840 /* Scan codes 0x00 (no valid translation) and 0x80 (extended flag) are ignored: */ 841 if (!(uScan & 0x7F)) 861 842 { 862 843 fResult = true; 863 844 break; 864 845 } 865 /* Re-create the bizarre scan code: */ 866 uScan |= 0x80; 867 } 868 869 /* Translate the keycode to a keysym: */ 870 KeySym ks = ::wrapXkbKeycodeToKeysym(NativeWindowSubsystem::X11GetDisplay(), pKeyEvent->detail, 0, 0); 871 872 /* Update special flags: */ 873 switch (ks) 874 { 875 case XK_Print: 876 iflags |= KeyPrint; 877 break; 878 case XK_Pause: 879 if (pKeyEvent->state & ControlMask) /* Break */ 846 847 /* Calculate flags: */ 848 int iflags = 0; 849 if (uScan >> 8) 850 iflags |= KeyExtended; 851 if ((pEvent->response_type & ~0x80) == XCB_KEY_PRESS) 852 iflags |= KeyPressed; 853 854 /* Remove the extended flag: */ 855 uScan &= 0x7F; 856 857 /* Special Korean keys must send scan code 0xF1/0xF2 858 * when pressed and nothing when released. */ 859 if (uScan == 0x71 || uScan == 0x72) 860 { 861 if ((pEvent->response_type & ~0x80) == XCB_KEY_RELEASE) 880 862 { 881 ks = XK_Break; 882 iflags |= KeyExtended; 883 uScan = 0x46; 863 fResult = true; 864 break; 884 865 } 885 else 886 iflags |= KeyPause; 887 break; 888 } 889 890 /* Finally, handle parsed key-event: */ 891 fResult = keyEvent(ks, uScan, iflags, uScreenId); 892 893 break; 894 } 895 default: 896 break; 866 /* Re-create the bizarre scan code: */ 867 uScan |= 0x80; 868 } 869 870 /* Translate the keycode to a keysym: */ 871 KeySym ks = ::wrapXkbKeycodeToKeysym(NativeWindowSubsystem::X11GetDisplay(), pKeyEvent->detail, 0, 0); 872 873 /* Update special flags: */ 874 switch (ks) 875 { 876 case XK_Print: 877 iflags |= KeyPrint; 878 break; 879 case XK_Pause: 880 if (pKeyEvent->state & ControlMask) /* Break */ 881 { 882 ks = XK_Break; 883 iflags |= KeyExtended; 884 uScan = 0x46; 885 } 886 else 887 iflags |= KeyPause; 888 break; 889 } 890 891 /* Finally, handle parsed key-event: */ 892 fResult = keyEvent(ks, uScan, iflags, uScreenId); 893 894 break; 895 } 896 default: 897 break; 898 } 897 899 } 898 900
Note:
See TracChangeset
for help on using the changeset viewer.