Modifier states returned from x backend should be 100% correct now
This commit is contained in:
		
							parent
							
								
									941a78eaf1
								
							
						
					
					
						commit
						e588d7d791
					
				| @ -113,13 +113,14 @@ func (backend *Backend) handleKeyPress ( | ||||
| 	keyEvent    := *event.KeyPressEvent | ||||
| 	button, num := backend.keycodeToButton(keyEvent.Detail, keyEvent.State) | ||||
| 	backend.callbackManager.RunPress (button, stone.Modifiers { | ||||
| 		// FIXME these may not be correct in all cases | ||||
| 		Shift:   (keyEvent.State & xproto.ModMaskShift)   > 0, | ||||
| 		Shift: | ||||
| 			(keyEvent.State & xproto.ModMaskShift)             > 0 || | ||||
| 			(keyEvent.State & backend.modifierMasks.shiftLock) > 0, | ||||
| 		Control: (keyEvent.State & xproto.ModMaskControl)       > 0, | ||||
| 		Alt:     (keyEvent.State & xproto.ModMask1)       > 0, | ||||
| 		// Meta:    (keyEvent.State & xproto.??)       > 0, | ||||
| 		Super:   (keyEvent.State & xproto.ModMask4)       > 0, | ||||
| 		// Hyper:   (keyEvent.State & xproto.??)       > 0, | ||||
| 		Alt:     (keyEvent.State & backend.modifierMasks.alt)   > 0, | ||||
| 		Meta:    (keyEvent.State & backend.modifierMasks.meta)  > 0, | ||||
| 		Super:   (keyEvent.State & backend.modifierMasks.super) > 0, | ||||
| 		Hyper:   (keyEvent.State & backend.modifierMasks.hyper) > 0, | ||||
| 		NumberPad: num, | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| @ -82,6 +82,11 @@ func factory ( | ||||
| 	backend.modifierMasks.numLock    = backend.keysymToMask(0xFF7F) | ||||
| 	backend.modifierMasks.modeSwitch = backend.keysymToMask(0xFF7E) | ||||
| 	 | ||||
| 	backend.modifierMasks.hyper = backend.keysymToMask(0xffed) | ||||
| 	backend.modifierMasks.super = backend.keysymToMask(0xffeb) | ||||
| 	backend.modifierMasks.meta  = backend.keysymToMask(0xffe7) | ||||
| 	backend.modifierMasks.alt   = backend.keysymToMask(0xffe9) | ||||
| 
 | ||||
| 	// create the window | ||||
| 	backend.window.Create ( | ||||
| 		backend.connection.RootWin(), | ||||
|  | ||||
| @ -48,6 +48,11 @@ type Backend struct { | ||||
| 		shiftLock  uint16 | ||||
| 		numLock    uint16 | ||||
| 		modeSwitch uint16 | ||||
| 
 | ||||
| 		alt   uint16 | ||||
| 		meta  uint16 | ||||
| 		super uint16 | ||||
| 		hyper uint16 | ||||
| 	} | ||||
| 
 | ||||
| 	windowBoundsClean bool | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| package main | ||||
| 
 | ||||
| import "os" | ||||
| import "fmt" | ||||
| import "image" | ||||
| import _ "image/png" | ||||
| import "git.tebibyte.media/sashakoshka/stone" | ||||
| @ -33,9 +34,18 @@ func main () { | ||||
| } | ||||
| 
 | ||||
| func onPress (button stone.Button, modifiers stone.Modifiers) { | ||||
| 	println("press", button) | ||||
| 	fmt.Printf ( | ||||
| 		"=>>\t0x%X\tsh: %t\tctrl: %t\talt: %t\tm: %t\ts: %t \th: %t\tnumpad: %t\n", | ||||
| 		button, | ||||
| 		modifiers.Shift, | ||||
| 		modifiers.Control, | ||||
| 		modifiers.Alt, | ||||
| 		modifiers.Meta, | ||||
| 		modifiers.Super, | ||||
| 		modifiers.Hyper, | ||||
| 		modifiers.NumberPad) | ||||
| } | ||||
| 
 | ||||
| func onRelease (button stone.Button) { | ||||
| 	println("release", button) | ||||
| 	fmt.Printf("<--\t0x%X\n", button) | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user