Update: update and remove some old code

This commit is contained in:
vcaesar 2023-07-06 10:14:42 -07:00
parent 6fa2f418fa
commit 5c3cbd6e17
3 changed files with 180 additions and 181 deletions

View File

@ -87,9 +87,8 @@ static io_connect_t _getAuxiliaryKeyDriver(void) {
}
return sEventDrvrRef;
}
#endif
#elif defined(IS_WINDOWS)
#if defined(IS_WINDOWS)
void win32KeyEvent(int key, MMKeyFlags flags, uintptr pid, int8_t isPid) {
int scan = MapVirtualKey(key & 0xff, MAPVK_VK_TO_VSC);
@ -284,38 +283,8 @@ void toggleUnicode(UniChar ch, const bool down, uintptr pid) {
SendTo(pid, keyEvent);
}
#endif
#if defined(USE_X11)
#else
#define toggleUniKey(c, down) toggleKey(c, down, MOD_NONE, 0)
int input_utf(const char *utf) {
Display *dpy = XOpenDisplay(NULL);
KeySym sym = XStringToKeysym(utf);
// KeySym sym = XKeycodeToKeysym(dpy, utf);
int min, max, numcodes;
XDisplayKeycodes(dpy, &min, &max);
KeySym *keysym;
keysym = XGetKeyboardMapping(dpy, min, max-min+1, &numcodes);
keysym[(max-min-1)*numcodes] = sym;
XChangeKeyboardMapping(dpy, min, numcodes, keysym, (max-min));
XFree(keysym);
XFlush(dpy);
KeyCode code = XKeysymToKeycode(dpy, sym);
XTestFakeKeyEvent(dpy, code, True, 1);
XTestFakeKeyEvent(dpy, code, False, 1);
XFlush(dpy);
XCloseDisplay(dpy);
return 0;
}
#endif
#if !defined(USE_X11)
int input_utf(const char *utf){
return 0;
}
#endif
// unicode type
@ -355,3 +324,32 @@ void unicodeType(const unsigned value, uintptr pid, int8_t isPid){
toggleUniKey(value, false);
#endif
}
#if defined(USE_X11)
int input_utf(const char *utf) {
Display *dpy = XOpenDisplay(NULL);
KeySym sym = XStringToKeysym(utf);
// KeySym sym = XKeycodeToKeysym(dpy, utf);
int min, max, numcodes;
XDisplayKeycodes(dpy, &min, &max);
KeySym *keysym;
keysym = XGetKeyboardMapping(dpy, min, max-min+1, &numcodes);
keysym[(max-min-1)*numcodes] = sym;
XChangeKeyboardMapping(dpy, min, numcodes, keysym, (max-min));
XFree(keysym);
XFlush(dpy);
KeyCode code = XKeysymToKeycode(dpy, sym);
XTestFakeKeyEvent(dpy, code, True, 1);
XTestFakeKeyEvent(dpy, code, False, 1);
XFlush(dpy);
XCloseDisplay(dpy);
return 0;
}
#else
int input_utf(const char *utf){
return 0;
}
#endif

View File

@ -54,7 +54,8 @@ MMBitmapRef copyMMBitmapFromDisplayInRect(MMRectInt32 rect, int32_t display_id,
MMPointInt32 o = rect.origin; MMSizeInt32 s = rect.size;
XImage *image = XGetImage(display, XDefaultRootWindow(display),
(int)o.x, (int)o.y, (unsigned int)s.w, (unsigned int)s.h, AllPlanes, ZPixmap);
(int)o.x, (int)o.y, (unsigned int)s.w, (unsigned int)s.h,
AllPlanes, ZPixmap);
XCloseDisplay(display);
if (image == NULL) { return NULL; }