|
@@ -590,6 +590,7 @@ int la_CreateSystemWindow(laWindow *window, int SyncToVBlank){
|
|
|
RECT rc; GetClientRect(window->win, &rc);
|
|
|
window->CW = rc.right - rc.left;
|
|
|
window->CH = rc.bottom - rc.top;
|
|
|
+ window->himc = ImmCreateContext();
|
|
|
#endif
|
|
|
#ifdef LA_LINUX
|
|
|
XWindowAttributes attr;
|
|
@@ -668,8 +669,15 @@ void laRenameWindow(laWindow* wnd, char* name){
|
|
|
XStoreName(MAIN.dpy, wnd->win, name);
|
|
|
#endif
|
|
|
#ifdef _WIN32
|
|
|
- //wchar_t buf[128]; MultiByteToWideChar(CP_UTF8, 0, name, -1, buf, 128);
|
|
|
- SetWindowTextW(wnd->win, name);
|
|
|
+ int wlen=strlen(name)+1;
|
|
|
+ int unisize=MultiByteToWideChar(CP_UTF8, 0, name, -1, 0, 0);
|
|
|
+ WCHAR *unistr=malloc(wlen*sizeof(WCHAR));
|
|
|
+ MultiByteToWideChar(CP_UTF8, 0, name, -1, unistr, unisize);
|
|
|
+ int bufsize=WideCharToMultiByte(CP_ACP, 0, unistr, -1, 0, 0, 0, 0);
|
|
|
+ char* acpstr = malloc(bufsize);
|
|
|
+ WideCharToMultiByte(CP_ACP, 0, unistr, -1, acpstr, bufsize, 0, 0);
|
|
|
+ SetWindowText(wnd->win, acpstr);
|
|
|
+ free(unistr); free(acpstr);
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -2173,6 +2181,11 @@ void la_SendSignalEvent(SYSWINDOW* hwnd, int signal){
|
|
|
e->key = signal;
|
|
|
la_SaveEvent(hwnd, e, 1);
|
|
|
};
|
|
|
+void la_SendPasteEvent(SYSWINDOW* hwnd) {
|
|
|
+ laEvent* e = memAcquireSimple(sizeof(laEvent));
|
|
|
+ e->type = LA_PASTE;
|
|
|
+ la_SaveEvent(hwnd, e, 1);
|
|
|
+};
|
|
|
void la_SendOperatorEvent(SYSWINDOW* hwnd, laOperatorType* at, int use_base, char* instructions){
|
|
|
if(!at){ return; }
|
|
|
laEvent *e = memAcquireSimple(sizeof(laEvent));
|
|
@@ -3871,6 +3884,7 @@ laPanel *laDesignPropPanel(char *Title, int X, int Y, int W, int H,
|
|
|
strSafeSet(&p->Title, Title);
|
|
|
|
|
|
if (Define){
|
|
|
+ if (!This) { This = &p->PP; }
|
|
|
Define(laPrepareUi(p), This, OperatorProps, NULL, 0);
|
|
|
}
|
|
|
|
|
@@ -7989,11 +8003,11 @@ LRESULT CALLBACK LA_WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
|
|
|
break;
|
|
|
|
|
|
case WM_SYSKEYDOWN:
|
|
|
- if (lparam & 0x40000000) break;
|
|
|
+ //if (lparam & 0x40000000) break;
|
|
|
la_SendKeyboardEvent(hwnd, LA_KEY_DOWN, la_TranslateSpecialKey(wparam));
|
|
|
break;
|
|
|
case WM_KEYDOWN:
|
|
|
- if (lparam & 0x40000000) break;
|
|
|
+ //if (lparam & 0x40000000) break;
|
|
|
vkey = wparam;
|
|
|
la_SendKeyboardEvent(hwnd, LA_KEY_DOWN, la_TranslateSpecialKey(vkey));
|
|
|
break;
|
|
@@ -8007,7 +8021,9 @@ LRESULT CALLBACK LA_WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
|
|
|
la_SendInputEvent(hwnd, wparam);
|
|
|
break;
|
|
|
case WM_IME_CHAR:
|
|
|
- la_SendInputEvent(hwnd, wparam);
|
|
|
+ char character[3]; character[0]=(BYTE)(wparam>>8); character[1] = wparam; character[2]=0;
|
|
|
+ wchar_t buf[10]; MultiByteToWideChar(CP_ACP, 0, character, -1, buf, 9);
|
|
|
+ la_SendInputEvent(hwnd, buf[0]);
|
|
|
return 0;
|
|
|
case WM_CHAR:
|
|
|
la_SendInputEvent(hwnd, wparam);
|
|
@@ -8165,6 +8181,7 @@ int la_HandleSingleEvent(laEvent *e, laListHandle *Operators){
|
|
|
a->ConfirmData = NextConfirmData;
|
|
|
}
|
|
|
}
|
|
|
+ if (e->type==LA_PASTE && MAIN.PasteString) strSafeDestroy(&MAIN.PasteString);
|
|
|
return 1;
|
|
|
}
|
|
|
int la_HandleEvents(laWindow *w){
|
|
@@ -8212,7 +8229,7 @@ int la_HandleEvents(laWindow *w){
|
|
|
la_UpdateOperatorHints(w);
|
|
|
return 1;
|
|
|
}
|
|
|
-int la_AllowInput(uint32_t ch){
|
|
|
+int la_AccpetedUnicodeInput(uint32_t ch){
|
|
|
if(ch>=32 || ch==U'\n' || ch==U'\t' || ch==U'\b') return 1;
|
|
|
return 0;
|
|
|
}
|
|
@@ -8223,9 +8240,31 @@ int laCopyToClipboard(unsigned char * text){
|
|
|
if (XGetSelectionOwner (MAIN.dpy, MAIN.selection) != window) return 0;
|
|
|
strSafeSet(&MAIN.CopyPending, text);
|
|
|
return 1;
|
|
|
+#endif
|
|
|
+#ifdef _WIN32
|
|
|
+ OpenClipboard(GetDesktopWindow());
|
|
|
+ EmptyClipboard();
|
|
|
+ size_t allocsize = strlen(text) + 1;
|
|
|
+ HGLOBAL hg = GlobalAlloc(GMEM_MOVEABLE, allocsize);
|
|
|
+ if (!hg){ CloseClipboard(); return; }
|
|
|
+ memcpy(GlobalLock(hg), text, allocsize);
|
|
|
+ GlobalUnlock(hg);
|
|
|
+ SetClipboardData(CF_TEXT, hg);
|
|
|
+ CloseClipboard();
|
|
|
+ GlobalFree(hg);
|
|
|
#endif
|
|
|
return 0;
|
|
|
}
|
|
|
+void laDisableIME(laWindow* w) {
|
|
|
+#ifdef _WIN32
|
|
|
+ ImmAssociateContext(w->win, 0);
|
|
|
+#endif
|
|
|
+}
|
|
|
+void laEnableIME(laWindow* w) {
|
|
|
+#ifdef _WIN32
|
|
|
+ if(w->himc) ImmAssociateContext(w->win, w->himc);
|
|
|
+#endif
|
|
|
+}
|
|
|
int la_ProcessSysMessage(){
|
|
|
int SendDelay = 0, SendIdle = 0;
|
|
|
if (!MAIN.DelayTriggered && MAIN.TimeAccum - MAIN.DelayStart > MAIN.DelayTime) SendDelay = 1;
|
|
@@ -8287,7 +8326,7 @@ int la_ProcessSysMessage(){
|
|
|
if (InputStatus==XBufferOverflow) printf("XInputBufferOverflow\n");
|
|
|
if (InputStatus == XLookupKeySym || InputStatus == XLookupBoth) { /*printf("status: %d\n", InputStatus);*/ }
|
|
|
if (InputCount){ MAIN.InputBuf[InputCount]=0; } strToUnicode(MAIN.InputBufU,MAIN.InputBuf); int UCount=strlenU(MAIN.InputBufU);
|
|
|
- for(int i=0;i<UCount;i++){ if(la_AllowInput(MAIN.InputBufU[i])) la_SendInputEvent(e.xkey.window, MAIN.InputBufU[i]); }
|
|
|
+ for(int i=0;i<UCount;i++){ if(la_AccpetedUnicodeInput(MAIN.InputBufU[i])) la_SendInputEvent(e.xkey.window, MAIN.InputBufU[i]); }
|
|
|
XKeyboardState x; XGetKeyboardControl(MAIN.dpy, &x);
|
|
|
int numlock=0; if(x.led_mask & 2){ numlock=1; }
|
|
|
if(InputKeysym=XkbKeycodeToKeysym(e.xkey.display, e.xkey.keycode, 0, 0)){
|
|
@@ -8317,12 +8356,7 @@ int la_ProcessSysMessage(){
|
|
|
&fmtid, &resbits, &ressize, &restail, (unsigned char**)&result);
|
|
|
|
|
|
if (fmtid == MAIN.incrid) logPrintNew("Pasted buffer is too large and INCR reading is not implemented yet.\n");
|
|
|
- else if(result) {
|
|
|
- arrEnsureLength(&MAIN.InputBufU, strlen(result), &MAIN.InputBufUMax, sizeof(uint32_t));
|
|
|
- strToUnicode(MAIN.InputBufU,result); int UCount=strlenU(MAIN.InputBufU);
|
|
|
- for(int i=0;i<UCount;i++){ if(la_AllowInput(MAIN.InputBufU[i])) la_SendInputEvent(e.xkey.window, MAIN.InputBufU[i]); }
|
|
|
- }
|
|
|
-
|
|
|
+ else if(result) { strSafeSet(&MAIN.PasteString,result); }
|
|
|
XFree(result);
|
|
|
return True;
|
|
|
}
|
|
@@ -8356,9 +8390,9 @@ int la_ProcessSysMessage(){
|
|
|
if (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE) != 0) Processed = 1;
|
|
|
|
|
|
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
|
|
|
- if (msg.wParam == VK_PROCESSKEY) {
|
|
|
- msg.wParam = ImmGetVirtualKey(msg.hwnd);
|
|
|
- }
|
|
|
+ //if (msg.wParam == VK_PROCESSKEY) {
|
|
|
+ // msg.wParam = ImmGetVirtualKey(msg.hwnd);
|
|
|
+ //}
|
|
|
TranslateMessage(&msg); DispatchMessage(&msg);
|
|
|
SendIdle = 0; MAIN.IdleStart = MAIN.TimeAccum; MAIN.IdleTriggered = 0;
|
|
|
};
|
|
@@ -9215,6 +9249,7 @@ void la_request_permission(const char* permission) {
|
|
|
|
|
|
#ifndef LAGUI_ANDROID
|
|
|
void la_DisplayKeyboard(bool pShow) {
|
|
|
+ if(pShow){ laEnableIME(MAIN.CurrentWindow); } else { laDisableIME(MAIN.CurrentWindow); }
|
|
|
return;
|
|
|
}
|
|
|
void la_HideNavBar(){
|