Skip to content

Commit

Permalink
Simplify menu overlay code and support multiple menus appearing
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed May 26, 2024
1 parent 5a446a3 commit e2150fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
16 changes: 6 additions & 10 deletions internal/x11/wm/desk.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ type x11WM struct {

currentBindings []*fynedesk.Shortcut

died bool
rootID, menuID xproto.Window
menuSize fyne.Size
menuPos fyne.Position
menuWin fyne.Window
transientMap map[xproto.Window][]xproto.Window
oldRoot *xgraphics.Image
died bool
rootID xproto.Window
menuSize fyne.Size
menuPos fyne.Position
transientMap map[xproto.Window][]xproto.Window
oldRoot *xgraphics.Image
}

type moveResizeType uint32
Expand Down Expand Up @@ -247,7 +246,6 @@ func (x *x11WM) ShowOverlay(w fyne.Window, s fyne.Size, p fyne.Position) {
w.Show()
x.menuSize = s
x.menuPos = p
x.menuWin = w
}

func (x *x11WM) ShowMenuOverlay(m *fyne.Menu, s fyne.Size, p fyne.Position) {
Expand Down Expand Up @@ -289,7 +287,6 @@ func (x *x11WM) ShowModal(w fyne.Window, s fyne.Size) {
p := fyne.NewPos((float32(root.Width)/scale-s.Width)/2, (float32(root.Height)/scale-s.Height)/2)

x.menuPos = p
x.menuWin = w
}

func (x *x11WM) X() *xgbutil.XUtil {
Expand Down Expand Up @@ -743,7 +740,6 @@ func (x *x11WM) showWindow(win xproto.Window, parent xproto.Window) {
if name == windowNameMenu {
x11.WindowExtendedHintsAdd(x.x, win, "_NET_WM_STATE_SKIP_TASKBAR")
x11.WindowExtendedHintsAdd(x.x, win, "_NET_WM_STATE_SKIP_PAGER")
x.menuID = win
xproto.ChangeWindowAttributes(x.Conn(), win, xproto.CwEventMask, []uint32{xproto.EventMaskLeaveWindow})

screen := fynedesk.Instance().Screens().Primary()
Expand Down
10 changes: 5 additions & 5 deletions internal/x11/wm/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ func (x *x11WM) handleMouseEnter(ev xproto.EnterNotifyEvent) {
}

func (x *x11WM) handleMouseLeave(ev xproto.LeaveNotifyEvent) {
if ev.Event == x.menuID { // dismiss overlay menus on mouse out
x.menuID = 0
if x.menuWin != nil {
x.menuWin.Close()
x.menuWin = nil
win := x.clientForWin(ev.Event)
if win == nil {
// dismiss overlay menus on mouse out
if x11.WindowName(x.X(), ev.Event) == windowNameMenu {
xproto.UnmapWindow(x.x.Conn(), ev.Event)
}
}

Expand Down

0 comments on commit e2150fa

Please sign in to comment.