Ok it kind of works now
This commit is contained in:
parent
da47026d1c
commit
2987331a31
@ -146,6 +146,8 @@ func (window *window) handleKeyPress (
|
||||
child.HandleUnfocus()
|
||||
}
|
||||
}
|
||||
} else if key == input.KeyEscape && window.shy {
|
||||
window.Close()
|
||||
} else if child, ok := window.child.(tomo.KeyboardTarget); ok {
|
||||
child.HandleKeyDown(key, modifiers)
|
||||
}
|
||||
@ -193,7 +195,14 @@ func (window *window) handleButtonPress (
|
||||
if window.hasModal { return }
|
||||
|
||||
buttonEvent := *event.ButtonPressEvent
|
||||
if buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7 {
|
||||
|
||||
insideWindow := image.Pt (
|
||||
int(buttonEvent.EventX),
|
||||
int(buttonEvent.EventY)).In(window.metrics.bounds)
|
||||
|
||||
if !insideWindow && window.shy {
|
||||
window.Close()
|
||||
} else if buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7 {
|
||||
if child, ok := window.child.(tomo.ScrollTarget); ok {
|
||||
sum := scrollSum { }
|
||||
sum.add(buttonEvent.Detail, window, buttonEvent.State)
|
||||
|
@ -30,6 +30,7 @@ type window struct {
|
||||
|
||||
modalParent *window
|
||||
hasModal bool
|
||||
shy bool
|
||||
|
||||
theme tomo.Theme
|
||||
config tomo.Config
|
||||
@ -286,10 +287,7 @@ func (window *window) NewMenu (bounds image.Rectangle) (tomo.MenuWindow, error)
|
||||
window.backend.connection,
|
||||
menu.xWindow.Id,
|
||||
window.xWindow.Id)
|
||||
ewmh.WmStateSet (
|
||||
window.backend.connection,
|
||||
menu.xWindow.Id,
|
||||
[]string { "_NET_WM_STATE_SKIP_TASKBAR" })
|
||||
menu.setType("POPUP_MENU")
|
||||
menu.inheritProperties(window)
|
||||
return menuWindow { window: menu }, err
|
||||
}
|
||||
@ -310,7 +308,9 @@ func (window mainWindow) NewPanel (bounds image.Rectangle) (tomo.Window, error)
|
||||
}
|
||||
|
||||
func (window menuWindow) Pin () {
|
||||
// TODO
|
||||
// TODO take off override redirect
|
||||
// TODO turn off shy
|
||||
// TODO set window type to MENU
|
||||
}
|
||||
|
||||
func (window *window) inheritProperties (parent *window) {
|
||||
|
@ -65,6 +65,17 @@ func run () {
|
||||
})
|
||||
container.Adopt(errorButton, false)
|
||||
|
||||
menuButton := elements.NewButton("menu")
|
||||
menuButton.OnClick (func () {
|
||||
menu, err := window.NewMenu (
|
||||
tomo.Bounds(0, 0, 64, 64).
|
||||
Add(menuButton.Bounds().Min))
|
||||
if err != nil { println(err.Error()) }
|
||||
menu.Adopt(elements.NewLabel("I'm a shy window...", true))
|
||||
menu.Show()
|
||||
})
|
||||
container.Adopt(menuButton, false)
|
||||
|
||||
cancelButton := elements.NewButton("No thank you.")
|
||||
cancelButton.OnClick(tomo.Stop)
|
||||
container.Adopt(cancelButton, false)
|
||||
|
Reference in New Issue
Block a user