Menu windows actually work properly now
This commit is contained in:
parent
2987331a31
commit
d67aac3d4f
@ -198,11 +198,13 @@ func (window *window) handleButtonPress (
|
||||
|
||||
insideWindow := image.Pt (
|
||||
int(buttonEvent.EventX),
|
||||
int(buttonEvent.EventY)).In(window.metrics.bounds)
|
||||
int(buttonEvent.EventY)).In(window.canvas.Bounds())
|
||||
|
||||
scrolling := buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7
|
||||
|
||||
if !insideWindow && window.shy {
|
||||
if !insideWindow && window.shy && !scrolling {
|
||||
window.Close()
|
||||
} else if buttonEvent.Detail >= 4 && buttonEvent.Detail <= 7 {
|
||||
} else if scrolling {
|
||||
if child, ok := window.child.(tomo.ScrollTarget); ok {
|
||||
sum := scrollSum { }
|
||||
sum.add(buttonEvent.Detail, window, buttonEvent.State)
|
||||
|
@ -8,6 +8,8 @@ import "github.com/jezek/xgbutil/icccm"
|
||||
import "github.com/jezek/xgbutil/xprop"
|
||||
import "github.com/jezek/xgbutil/xevent"
|
||||
import "github.com/jezek/xgbutil/xwindow"
|
||||
import "github.com/jezek/xgbutil/keybind"
|
||||
import "github.com/jezek/xgbutil/mousebind"
|
||||
import "github.com/jezek/xgbutil/xgraphics"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/data"
|
||||
@ -283,6 +285,7 @@ func (window *window) NewModal (bounds image.Rectangle) (tomo.Window, error) {
|
||||
func (window *window) NewMenu (bounds image.Rectangle) (tomo.MenuWindow, error) {
|
||||
menu, err := window.backend.newWindow (
|
||||
bounds.Add(window.metrics.bounds.Min), true)
|
||||
menu.shy = true
|
||||
icccm.WmTransientForSet (
|
||||
window.backend.connection,
|
||||
menu.xWindow.Id,
|
||||
@ -311,6 +314,21 @@ func (window menuWindow) Pin () {
|
||||
// TODO take off override redirect
|
||||
// TODO turn off shy
|
||||
// TODO set window type to MENU
|
||||
// TODO iungrab keyboard and mouse
|
||||
}
|
||||
|
||||
func (window *window) grabInput () {
|
||||
keybind.GrabKeyboard(window.backend.connection, window.xWindow.Id)
|
||||
mousebind.GrabPointer (
|
||||
window.backend.connection,
|
||||
window.xWindow.Id,
|
||||
window.backend.connection.RootWin(), 0)
|
||||
window.xWindow.Focus()
|
||||
}
|
||||
|
||||
func (window *window) ungrabInput () {
|
||||
keybind.UngrabKeyboard(window.backend.connection)
|
||||
mousebind.UngrabPointer(window.backend.connection)
|
||||
}
|
||||
|
||||
func (window *window) inheritProperties (parent *window) {
|
||||
@ -347,10 +365,12 @@ func (window *window) Show () {
|
||||
}
|
||||
|
||||
window.xWindow.Map()
|
||||
if window.shy { window.grabInput() }
|
||||
}
|
||||
|
||||
func (window *window) Hide () {
|
||||
window.xWindow.Unmap()
|
||||
if window.shy { window.ungrabInput() }
|
||||
}
|
||||
|
||||
func (window *window) Copy (data data.Data) {
|
||||
|
@ -5,6 +5,8 @@ import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "github.com/jezek/xgbutil"
|
||||
import "github.com/jezek/xgb/xproto"
|
||||
import "github.com/jezek/xgbutil/xevent"
|
||||
import "github.com/jezek/xgbutil/keybind"
|
||||
import "github.com/jezek/xgbutil/mousebind"
|
||||
|
||||
// Backend is an instance of an X backend.
|
||||
type Backend struct {
|
||||
@ -45,6 +47,9 @@ func NewBackend () (output tomo.Backend, err error) {
|
||||
if err != nil { return }
|
||||
backend.initializeKeymapInformation()
|
||||
|
||||
keybind.Initialize(backend.connection)
|
||||
mousebind.Initialize(backend.connection)
|
||||
|
||||
output = backend
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user