Mouse events are no longer given to windows with a modal active

This commit is contained in:
Sasha Koshka 2023-04-27 00:05:29 -04:00
parent 4e20726eff
commit 990e60eea4

View File

@ -143,6 +143,8 @@ func (window *window) handleKeyRelease (
connection *xgbutil.XUtil, connection *xgbutil.XUtil,
event xevent.KeyReleaseEvent, event xevent.KeyReleaseEvent,
) { ) {
if window.hasModal { return }
keyEvent := *event.KeyReleaseEvent keyEvent := *event.KeyReleaseEvent
// do not process this event if it was generated from a key repeat // do not process this event if it was generated from a key repeat
@ -219,6 +221,8 @@ func (window *window) handleButtonRelease (
connection *xgbutil.XUtil, connection *xgbutil.XUtil,
event xevent.ButtonReleaseEvent, event xevent.ButtonReleaseEvent,
) { ) {
if window.hasModal { return }
buttonEvent := *event.ButtonReleaseEvent buttonEvent := *event.ButtonReleaseEvent
if buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7 { return } if buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7 { return }
modifiers := window.modifiersFromState(buttonEvent.State) modifiers := window.modifiersFromState(buttonEvent.State)
@ -249,6 +253,8 @@ func (window *window) handleMotionNotify (
connection *xgbutil.XUtil, connection *xgbutil.XUtil,
event xevent.MotionNotifyEvent, event xevent.MotionNotifyEvent,
) { ) {
if window.hasModal { return }
motionEvent := window.compressMotionNotify(*event.MotionNotifyEvent) motionEvent := window.compressMotionNotify(*event.MotionNotifyEvent)
x := int(motionEvent.EventX) x := int(motionEvent.EventX)
y :=int(motionEvent.EventY) y :=int(motionEvent.EventY)