*/}}
Jelajahi Sumber

New special eky handling

YimingWu 1 tahun lalu
induk
melakukan
2e1245c42f
2 mengubah file dengan 11 tambahan dan 26 penghapusan
  1. 0 1
      la_interface.h
  2. 11 25
      la_kernel.c

+ 0 - 1
la_interface.h

@@ -310,7 +310,6 @@ STRUCTURE(LA){
 
     int InitDone;
 
-    int SpecialKeyStates;
     laKeyMapper KeyMap;
 
     laHash256 OperatorTypeHash;

+ 11 - 25
la_kernel.c

@@ -717,33 +717,22 @@ int la_OnWindowDestroy(Window wnd){
     return 0;
 }
 
-void la_MakeSpecialKeyBit(laEvent *e){
-    e->SpecialKeyBit = MAIN.SpecialKeyStates;
-}
-void la_RegisterSpecialKeys(laEvent* e){
-    if(e->Type&LA_STATE_DOWN){ MAIN.SpecialKeyStates|=e->key&LA_KEY_SPECIALS; }
-    elif(e->Type&LA_STATE_UP){ MAIN.SpecialKeyStates&=~(e->key&LA_KEY_SPECIALS); }
+void la_MakeSpecialKeyBit(Window*hwnd,laWindow*wnd,laEvent *e,int use_last_pos){
+    laListHandle *el = &wnd->EventList;
+    laEvent* last_e=el->pLast;
+    Window root_ret, win_ret; int rrx,rry,rx,ry,rmask;
+    XQueryPointer(MAIN.dpy, hwnd, &root_ret,&win_ret,&rrx,&rry,&rx,&ry,&rmask);
+    if(use_last_pos){ if(last_e){ e->x= last_e->x; e->y= last_e->y; }else{ e->x = rx; e->y = ry; } }
+    e->SpecialKeyBit = ((rmask&ShiftMask)?LA_KEY_SHIFT:0)|((rmask&ControlMask)?LA_KEY_CTRL:0)|((rmask&Mod1Mask)?LA_KEY_ALT:0);
 }
 void la_SaveEvent(Window hwnd, laEvent *e, int use_last_pos){
     laListHandle *wl = &MAIN.Windows;
-    laListHandle *el = 0;
-    laWindow *wnd = 0;
-
-    wnd = lstFindItem(hwnd, la_IsThisSysWindow, wl);
+    laWindow* wnd = lstFindItem(hwnd, la_IsThisSysWindow, wl);
     if (!wnd){ FreeMem(e); return; }
+    laListHandle *el = &wnd->EventList;
 
-    la_MakeSpecialKeyBit(e);
+    la_MakeSpecialKeyBit(hwnd,wnd,e,use_last_pos);
 
-    el = &wnd->EventList;
-    
-    if(use_last_pos){
-        laEvent* last_e=el->pLast;
-        if(last_e){ e->x= last_e->x; e->y= last_e->y; }else{
-            Window root_ret, win_ret; int rrx,rry,rx,ry,rmask;
-            XQueryPointer(MAIN.dpy, hwnd, &root_ret,&win_ret,&rrx,&rry,&rx,&ry,&rmask);
-            e->x = rx; e->y = ry;
-        }
-    }
     e->Pressure=MAIN.IsPen?(MAIN.PointerIsEraser?MAIN.EraserPressure:MAIN.StylusPressure):0.5f;
     e->AngleX=MAIN.PointerIsEraser?MAIN.EraserAngleX:MAIN.StylusAngleX;
     e->AngleY=MAIN.PointerIsEraser?MAIN.EraserAngleY:MAIN.StylusAngleY;
@@ -753,10 +742,7 @@ void la_SaveEvent(Window hwnd, laEvent *e, int use_last_pos){
     laMappingRequestEval();
 };
 void la_SendKeyboardEvent(Window hwnd, int type, int key){
-    laEvent *e = CreateNew(laEvent);
-    e->Type = type; e->key = key;
-    la_RegisterSpecialKeys(e);
-    printf("%d %lc\n",key,key);
+    laEvent *e = CreateNew(laEvent); e->Type = type; e->key = key;
     la_SaveEvent(hwnd, e, 1);
 };
 void la_SendInputEvent(Window hwnd, uint32_t Input){