Modal dialogs lock the window's input until they are closed
This commit is contained in:
parent
a2c0ff5f4c
commit
bdc1109bcf
@ -119,6 +119,7 @@ func (window *window) handleKeyPress (
|
|||||||
event xevent.KeyPressEvent,
|
event xevent.KeyPressEvent,
|
||||||
) {
|
) {
|
||||||
if window.child == nil { return }
|
if window.child == nil { return }
|
||||||
|
if window.hasModal { return }
|
||||||
|
|
||||||
keyEvent := *event.KeyPressEvent
|
keyEvent := *event.KeyPressEvent
|
||||||
key, numberPad := window.backend.keycodeToKey(keyEvent.Detail, keyEvent.State)
|
key, numberPad := window.backend.keycodeToKey(keyEvent.Detail, keyEvent.State)
|
||||||
@ -180,6 +181,7 @@ func (window *window) handleButtonPress (
|
|||||||
event xevent.ButtonPressEvent,
|
event xevent.ButtonPressEvent,
|
||||||
) {
|
) {
|
||||||
if window.child == nil { return }
|
if window.child == nil { return }
|
||||||
|
if window.hasModal { return }
|
||||||
|
|
||||||
buttonEvent := *event.ButtonPressEvent
|
buttonEvent := *event.ButtonPressEvent
|
||||||
if buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7 {
|
if buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7 {
|
||||||
|
@ -24,6 +24,9 @@ type window struct {
|
|||||||
onClose func ()
|
onClose func ()
|
||||||
skipChildDrawCallback bool
|
skipChildDrawCallback bool
|
||||||
|
|
||||||
|
modalParent *window
|
||||||
|
hasModal bool
|
||||||
|
|
||||||
theme theme.Theme
|
theme theme.Theme
|
||||||
config config.Config
|
config config.Config
|
||||||
|
|
||||||
@ -217,6 +220,8 @@ func (window *window) NewModal (width, height int) (elements.Window, error) {
|
|||||||
window.backend.connection,
|
window.backend.connection,
|
||||||
modal.xWindow.Id,
|
modal.xWindow.Id,
|
||||||
[]string { "_NET_WM_STATE_MODAL" })
|
[]string { "_NET_WM_STATE_MODAL" })
|
||||||
|
modal.modalParent = window
|
||||||
|
window.hasModal = true
|
||||||
return modal, err
|
return modal, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,6 +254,10 @@ func (window *window) Hide () {
|
|||||||
|
|
||||||
func (window *window) Close () {
|
func (window *window) Close () {
|
||||||
if window.onClose != nil { window.onClose() }
|
if window.onClose != nil { window.onClose() }
|
||||||
|
if window.modalParent != nil {
|
||||||
|
// we are a modal dialog, so unlock the parent
|
||||||
|
window.modalParent.hasModal = false
|
||||||
|
}
|
||||||
window.Hide()
|
window.Hide()
|
||||||
window.Adopt(nil)
|
window.Adopt(nil)
|
||||||
delete(window.backend.windows, window.xWindow.Id)
|
delete(window.backend.windows, window.xWindow.Id)
|
||||||
|
Reference in New Issue
Block a user