Skip to content

Commit

Permalink
fix: check icccm feature compatibility #64
Browse files Browse the repository at this point in the history
  • Loading branch information
leukipp committed Aug 16, 2024
1 parent ab7ddb0 commit 7e9b9b7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
16 changes: 9 additions & 7 deletions desktop/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ func (tr *Tracker) handleMaximizedClient(c *store.Client) {
// Update client states
c.Update()

// Reset maximization
// Unmaximize window
c.UnMaximize()

// Check window lifetime
// Activate maximized layout
if !c.IsNew() && ws.ActiveLayout().GetName() != "maximized" {
tr.Channels.Action <- "layout_maximized"
store.ActiveWindowSet(store.X, c.Window)
Expand Down Expand Up @@ -320,13 +320,12 @@ func (tr *Tracker) handleResizeClient(c *store.Client) {
pt := store.PointerUpdate(store.X)

// Set client resize event
if !tr.Handlers.ResizeClient.Active() {
if !c.IsNew() && !tr.Handlers.ResizeClient.Active() {
tr.Handlers.ResizeClient = &Handler{Dragging: pt.Dragging(500), Source: c}
}
log.Debug("Client resize handler fired [", c.Latest.Class, "]")

// Check window lifetime
if tr.Handlers.ResizeClient.Dragging && !c.IsNew() {
if tr.Handlers.ResizeClient.Dragging {

// Set client resize lock
if tr.Handlers.ResizeClient.Active() {
Expand Down Expand Up @@ -374,7 +373,7 @@ func (tr *Tracker) handleMoveClient(c *store.Client) {
pt := store.PointerUpdate(store.X)

// Set client move event
if !tr.Handlers.MoveClient.Active() {
if !c.IsNew() && !tr.Handlers.MoveClient.Active() {
tr.Handlers.MoveClient = &Handler{Dragging: pt.Dragging(500), Source: c}
}
log.Debug("Client move handler fired [", c.Latest.Class, "]")
Expand All @@ -389,7 +388,7 @@ func (tr *Tracker) handleMoveClient(c *store.Client) {

// Check if target point hovers another client
tr.Handlers.SwapClient.Reset()
if co := tr.ClientAt(ws, targetPoint); co != nil {
if co := tr.ClientAt(ws, targetPoint); co != nil && co != c {
tr.Handlers.SwapClient = &Handler{Source: c, Target: co}
log.Debug("Client swap handler active [", c.Latest.Class, "-", co.Latest.Class, "]")
}
Expand Down Expand Up @@ -567,6 +566,9 @@ func (tr *Tracker) attachHandlers(c *store.Client) {
// Handle structure events
tr.handleResizeClient(c)
tr.handleMoveClient(c)
if !tr.Handlers.MoveClient.Active() {
c.Update()
}
}).Connect(store.X, c.Window.Id)

// Attach property events
Expand Down
6 changes: 6 additions & 0 deletions store/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ func (c *Client) UnLock() {
}

func (c *Client) Limit(w, h int) bool {
if !Compatible("icccm.SizeHintPMinSize") {
return false
}

// Decoration extents
ext := c.Latest.Dimensions.Extents
Expand All @@ -114,6 +117,9 @@ func (c *Client) Limit(w, h int) bool {
}

func (c *Client) UnLimit() bool {
if !Compatible("icccm.SizeHintPMinSize") {
return false
}

// Restore window size limits
icccm.WmNormalHintsSet(X, c.Window.Id, &c.Cached.Dimensions.Hints.Normal)
Expand Down
12 changes: 12 additions & 0 deletions store/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ func Connected() bool {
return connected
}

func Compatible(feature string) bool {
wm := strings.ToLower(WindowManager.Name)

// Check feature compatibility
switch feature {
case "icccm.SizeHintPMinSize":
return !strings.Contains(wm, "mutter") && !strings.Contains(wm, "muffin")
}

return true
}

func NumberOfDesktopsGet(X *xgbutil.XUtil) uint {
deskCount, err := ewmh.NumberOfDesktopsGet(X)

Expand Down

0 comments on commit 7e9b9b7

Please sign in to comment.