Ticket #134: libview_fix_1_of_1_rev_57888ed51447_Issue__134__Added_generic_implementation_of___sendKeyOrButtonEvent_____to__DeviceWorkstation_.patch
File libview_fix_1_of_1_rev_57888ed51447_Issue__134__Added_generic_implementation_of___sendKeyOrButtonEvent_____to__DeviceWorkstation_.patch, 6.7 KB (added by , 6 years ago) |
---|
-
DeviceWorkstation.st
# HG changeset patch # User Jan Vrany <jan.vrany@fit.cvut.cz> # Date 1494066393 -3600 # Sat May 06 11:26:33 2017 +0100 # Branch jv # Node ID 57888ed51447bc974694e0b6b2543d59661a6978 # Parent 653376a94c8f90590160b75eeb2a0943f3d46ed0 Issue #134: Added generic implementation of `#sendKeyOrButtonEvent:..` to `DeviceWorkstation` ...as a fallback. This implementation works purely on a Smalltalk level by directly injecting (St/X) events in (St/X) window group's event queue, completely bypassing windowing system. The implementation is icomplete and is designed and tested only with UI testing framework (stx:goodies/sunit/ext/ui) to allow UI testing on systems with no specific implementation of `#sendKeyOrButtonEvent...` - e.g. Windows at the time. https://swing.fit.cvut.cz/projects/stx-jv/ticket/134 diff -r 653376a94c8f -r 57888ed51447 DeviceWorkstation.st
a b 5168 5168 The non-nil case is the lowlevel entry, where state must include any shift/ctrl information 5169 5169 (not very user friendly)" 5170 5170 5171 self subclassResponsibility 5171 "/ WARNING: this is a generic implementation that completely bypasses underlaying 5172 "/ system event queue. It may not be complete - it has been written as a quick hack 5173 "/ to make UI testing framework kind-of working on systems where there's no proper 5174 "/ implementation of this method (e.g., Windows at the time) 5175 5176 | view shiftWasDown ctrlWasDown altWasDown metaWasDown | 5177 5178 view := self viewFromId: targetId. 5179 5180 [ 5181 shiftWasDown := shiftDown. 5182 altWasDown := altDown. 5183 metaWasDown := metaDown. 5184 ctrlWasDown := ctrlDown. 5185 stateMask notNil ifTrue:[ 5186 shiftDown := (stateMask bitAnd: self shiftModifierMask) ~~ 0. 5187 altDown := (stateMask bitAnd: self altModifierMask) ~~ 0. 5188 metaDown := (stateMask bitAnd: self metaModifierMask) ~~ 0. 5189 ctrlDown := (stateMask bitAnd: self ctrlModifierMask) ~~ 0. 5190 ]. 5191 (typeSymbol == #keyPress or:[ typeSymbol == #keyRelease ]) ifTrue:[ 5192 | key | 5193 5194 key := keySymCodeOrButtonNr. 5195 (#(Left Right Up Down) includes: key) ifTrue:[ 5196 key := (#Cursor , key) asSymbol. 5197 ]. 5198 typeSymbol == #keyPress ifTrue:[ 5199 self keyPress:key x:1 y:1 view:view. 5200 ] ifFalse:[ 5201 self keyRelease:key x:1 y:1 view:view. 5202 ] 5203 ] ifFalse:[ 5204 self notYetImplemented. 5205 ]. 5206 ] ensure:[ 5207 shiftDown := shiftWasDown. 5208 altDown := altWasDown. 5209 metaDown := metaWasDown. 5210 ctrlDown := ctrlWasDown. 5211 ]. 5212 5213 "Modified (comment): / 06-05-2017 / 11:15:25 / jv" 5172 5214 ! 5173 5215 5174 5216 simulateKeyboardInput:aCharacterOrString inViewId:viewId -
WinWorkstation.st
diff -r 653376a94c8f -r 57888ed51447 WinWorkstation.st
a b 19 19 classVariableNames:'BeepDuration NativeDialogs NativeFileDialogs NativeWidgets 20 20 NativeWidgetClassTable StandardColorValues IgnoreSysColorChanges 21 21 IgnoreFontChanges SystemColorValues CanEndSession 22 VerboseNativeDialogs 22 VerboseNativeDialogs' 23 23 poolDictionaries:'' 24 24 category:'Interface-Graphics' 25 25 ! … … 6495 6495 ' Peak User Objects = ' errorPrint. counts second errorPrintCR. 6496 6496 ' # GDI Objects = ' errorPrint. counts third errorPrintCR. 6497 6497 ' Peak GDI Objects = ' errorPrint. counts fourth errorPrintCR. 6498 ! 6498 ! 6499 6499 6500 6500 printHandleCounts 6501 6501 "show prim values" … … 8090 8090 "Modified: / 28-01-2012 / 10:20:30 / cg" 8091 8091 ! 8092 8092 8093 destroyGC:aGCId8094 %{8095 if (__isExternalAddress(aGCId)) {8096 struct gcData *gcData = _GCDATA(aGCId);8097 8098 if (gcData == NULL) {8099 console_fprintf(stderr, "WinWorkstation [warning]: trying to destroy GC twice\n");8100 RETURN(self);8101 }8102 8103 #ifdef COUNT_RESOURCES8104 __cnt_gcData--;8105 RESPRINTF(("DestroyGcData %d\n",__cnt_gcData));8106 #endif8107 8108 #ifdef CACHE_LAST_DC8109 if (lastGcData == gcData) {8110 _releaseDC(gcData);8111 }8112 #endif8113 __ExternalAddressInstPtr(aGCId)->e_address = NULL;8114 8115 freeGcData(gcData);8116 }8117 %}8118 !8119 8120 destroyPixmap:aDrawableId8121 8122 %{ /* NOCONTEXT */8123 if (__isExternalAddress(aDrawableId) && ISCONNECTED) {8124 HANDLE bitmapHandle = _HANDLEVal(aDrawableId);8125 8126 if (bitmapHandle) {8127 #ifdef COUNT_BMP_RESOURCES8128 __cnt_bitmap--;8129 RES_BMP_PRINTF(("DestroyPixmap %x %d\n", bitmapHandle, __cnt_bitmap));8130 #endif8131 _DeleteObject(bitmapHandle, __LINE__);8132 }8133 }8134 %}8135 !8136 8137 destroyView:aView withId:aWindowId8138 self primDestroyView:aView withId:aWindowId.8139 self removeKnownView:aView withId:aWindowId8140 !8141 8142 8093 dcGetClipBoxForGC: gcId 8143 8094 "Return clipping box for given device context (as #(left top right bottom) ). " 8144 8095 … … 8201 8152 err:; 8202 8153 %}. 8203 8154 ^ self primitiveFailed: error 8204 ! 8155 ! 8205 8156 8206 8157 dcUnlockForGC:gcId 8207 8158 "Unlocks and __destroy__ a device context for given GC previously … … 8224 8175 err:; 8225 8176 %}. 8226 8177 ^ self primitiveFailed: error 8227 ! 8178 ! 8179 8180 destroyGC:aGCId 8181 %{ 8182 if (__isExternalAddress(aGCId)) { 8183 struct gcData *gcData = _GCDATA(aGCId); 8184 8185 if (gcData == NULL) { 8186 console_fprintf(stderr, "WinWorkstation [warning]: trying to destroy GC twice\n"); 8187 RETURN(self); 8188 } 8189 8190 #ifdef COUNT_RESOURCES 8191 __cnt_gcData--; 8192 RESPRINTF(("DestroyGcData %d\n",__cnt_gcData)); 8193 #endif 8194 8195 #ifdef CACHE_LAST_DC 8196 if (lastGcData == gcData) { 8197 _releaseDC(gcData); 8198 } 8199 #endif 8200 __ExternalAddressInstPtr(aGCId)->e_address = NULL; 8201 8202 freeGcData(gcData); 8203 } 8204 %} 8205 ! 8206 8207 destroyPixmap:aDrawableId 8208 8209 %{ /* NOCONTEXT */ 8210 if (__isExternalAddress(aDrawableId) && ISCONNECTED) { 8211 HANDLE bitmapHandle = _HANDLEVal(aDrawableId); 8212 8213 if (bitmapHandle) { 8214 #ifdef COUNT_BMP_RESOURCES 8215 __cnt_bitmap--; 8216 RES_BMP_PRINTF(("DestroyPixmap %x %d\n", bitmapHandle, __cnt_bitmap)); 8217 #endif 8218 _DeleteObject(bitmapHandle, __LINE__); 8219 } 8220 } 8221 %} 8222 ! 8223 8224 destroyView:aView withId:aWindowId 8225 self primDestroyView:aView withId:aWindowId. 8226 self removeKnownView:aView withId:aWindowId 8227 ! 8228 8228 8229 8229 gcFor:aDrawableId 8230 8230 … … 13171 13171 The non-nil case is the lowlevel entry, where state must include any shift/ctrl information 13172 13172 (not very user friendly)" 13173 13173 13174 'WinWorkstation [warning]: sendKeyOrButtonEvent unimplemented' infoPrintCR. 13175 ^ false 13174 super sendKeyOrButtonEvent:typeSymbol x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask toViewId:targetId 13175 13176 "Modified: / 06-05-2017 / 11:19:03 / jv" 13176 13177 ! ! 13177 13178 13178 13179 !WinWorkstation methodsFor:'font stuff'! … … 19612 19613 19613 19614 version_CVS 19614 19615 ^ '$Header$' 19616 ! 19617 19618 version_HG 19619 19620 ^ '$Changeset: <not expanded> $' 19615 19621 ! ! 19616 19622 19617 19623