diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.cpp b/uppsrc/ScatterCtrl/ScatterCtrl.cpp index 439469bed..a8f57a467 100644 --- a/uppsrc/ScatterCtrl/ScatterCtrl.cpp +++ b/uppsrc/ScatterCtrl/ScatterCtrl.cpp @@ -205,6 +205,10 @@ void ScatterCtrl::AddMouseBehavior(bool ctrl, bool alt, bool shift, bool left, b mouseBehavior << MouseBehavior(ctrl, alt, shift, left, middle, middlewheel, right, action); } +#ifdef PLATFORM_POSIX +int GetKeyCodeX(int key); +#endif + void ScatterCtrl::AddKeyBehavior(bool ctrl, bool alt, bool shift, int key, bool isVirtualKey, ScatterAction action) { if (!isVirtualKey) { @@ -213,17 +217,7 @@ void ScatterCtrl::AddKeyBehavior(bool ctrl, bool alt, bool shift, int key, bool key = VkKeyScanExW(key, hKeyboardLayout) + K_DELTA; } #else - XDisplay dpy; - if (!(dpy = XOpenDisplay(NULL))) - return; - - if (key > 0x00ff) - key = key | 0x01000000; - - key = XKeysymToKeycode(dpy, key) + K_DELTA; - - XFlush(dpy); - XCloseDisplay(dpy); + key = GetKeyCodeX(key); } #endif keyBehavior << KeyBehavior(ctrl, alt, shift, key, isVirtualKey, action); diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.upp b/uppsrc/ScatterCtrl/ScatterCtrl.upp index 5c0feaa93..5c67897fa 100644 --- a/uppsrc/ScatterCtrl/ScatterCtrl.upp +++ b/uppsrc/ScatterCtrl/ScatterCtrl.upp @@ -7,6 +7,7 @@ uses GridCtrl; file + ScatterCtrlX.cpp, ScatterCtrl.cpp, ScatterCtrl.h, Properties.cpp, diff --git a/uppsrc/ScatterCtrl/ScatterCtrlX.cpp b/uppsrc/ScatterCtrl/ScatterCtrlX.cpp new file mode 100644 index 000000000..3f9892a12 --- /dev/null +++ b/uppsrc/ScatterCtrl/ScatterCtrlX.cpp @@ -0,0 +1,30 @@ +#include + +#ifdef PLATFORM_POSIX + +#include +#include +#include +#include +#include + +NAMESPACE_UPP + +int GetKeyCodeX(int key) { + _XDisplay *dpy = XOpenDisplay(NULL); + if (!dpy) + return Null; + + if (key > 0x00ff) + key = key | 0x01000000; + + key = XKeysymToKeycode(dpy, key) + K_DELTA; + + XFlush(dpy); + XCloseDisplay(dpy); + return key; +} + +END_UPP_NAMESPACE + +#endif \ No newline at end of file