Skip to content

Commit

Permalink
fix: window moves between monitors #26
Browse files Browse the repository at this point in the history
  • Loading branch information
leukipp committed Jan 11, 2024
1 parent 31df236 commit 6ae1321
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
15 changes: 11 additions & 4 deletions desktop/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func (tr *Tracker) handleMoveClient(c *store.Client) {

if active && moved && !resized && !tr.Handler.ResizeClient.Active {
mg := ws.ActiveLayout().GetManager()
pt := store.PointerGet(store.X)
pt := store.PointerUpdate(store.X)

// Set client move event
if !tr.Handler.MoveClient.Active {
Expand Down Expand Up @@ -353,13 +353,12 @@ func (tr *Tracker) handleWorkspaceChange(c *store.Client) {
mg := ws.ActiveLayout().GetManager()
master := mg.IsMaster(c)
ws.RemoveClient(c)

// Tile current workspace
if ws.Enabled() {
ws.Tile()
}

// Reset screen swapping event
tr.Handler.SwapScreen.Active = false

// Update client desktop and screen
if !tr.isTrackable(c.Win.Id) {
return
Expand All @@ -368,16 +367,24 @@ func (tr *Tracker) handleWorkspaceChange(c *store.Client) {

// Add client to new workspace
ws = tr.ClientWorkspace(c)
if tr.Handler.SwapScreen.Active {
ws = tr.ActiveWorkspace()
}
mg = ws.ActiveLayout().GetManager()
ws.AddClient(c)
if master {
mg.MakeMaster(c)
}

// Tile new workspace
if ws.Enabled() {
ws.Tile()
} else {
c.Restore(false)
}

// Reset screen swapping event
tr.Handler.SwapScreen.Active = false
}

func (tr *Tracker) onStateUpdate(aname string) {
Expand Down
4 changes: 2 additions & 2 deletions input/mousebinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (

func BindMouse(tr *desktop.Tracker) {
poll(100, func() {
store.PointerUpdate(store.X)
pt := store.PointerUpdate(store.X)

// Update systray icon
ws := tr.ActiveWorkspace()
Expand All @@ -31,7 +31,7 @@ func BindMouse(tr *desktop.Tracker) {
hc := store.Corners[i]

wasActive := hc.Active
isActive := hc.IsActive(store.CurrentPointer)
isActive := hc.IsActive(pt)

if !wasActive && isActive {
log.Debug("Corner at position ", hc.Area, " is hot [", hc.Name, "]")
Expand Down
4 changes: 3 additions & 1 deletion store/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func DesktopDimensions(screenNum uint) (x, y, w, h int) {
return
}

func PointerUpdate(X *xgbutil.XUtil) {
func PointerUpdate(X *xgbutil.XUtil) *common.Pointer {

// Update current pointer
previousButton := uint16(0)
Expand All @@ -337,6 +337,8 @@ func PointerUpdate(X *xgbutil.XUtil) {

// Update current screen
CurrentScreen = ScreenNumGet(CurrentPointer)

return CurrentPointer
}

func StateUpdate(X *xgbutil.XUtil, e xevent.PropertyNotifyEvent) {
Expand Down

0 comments on commit 6ae1321

Please sign in to comment.