Skip to content

Commit

Permalink
Fullscreen fix (#64)
Browse files Browse the repository at this point in the history
* Fixed issue with some fullscreen applications.

* Now caching client geometry when fullscreening.

When unfullscreening, the old client geometry is restored.

* Updated version.

Co-authored-by: Avahe Kellenberger <[email protected]>
  • Loading branch information
crab-dev and avahe-kellenberger authored Jun 25, 2020
1 parent 608b470 commit 1b23711
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion nimdow.nimble
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Package
version = "0.5.7"
version = "0.5.8"
author = "avahe-kellenberger"
description = "A window manager written in nim"
license = "GPL v2"
Expand Down
2 changes: 1 addition & 1 deletion src/nimdow.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ when isMainModule:
if params.len == 1:
let param = params[0].string
if param == "-v" or param == "--version":
echo "Nimdow v0.5.7"
echo "Nimdow v0.5.8"
quit()
else:
# If given a parameter for a config file, use it instead of the default.
Expand Down
5 changes: 5 additions & 0 deletions src/nimdowpkg/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ type
Client* = ref object of RootObj
window*: Window
x*: int
oldX*: int
y*: int
oldY*: int
width*: uint
oldWidth*: uint
height*: uint
oldHeight*: uint
borderWidth*: uint
oldBorderWidth*: uint
isFullscreen*: bool
isFloating*: bool
# Non-resizable
Expand Down
29 changes: 17 additions & 12 deletions src/nimdowpkg/monitor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -454,20 +454,13 @@ proc toggleFullscreen*(this: Monitor, client: var Client) =
cast[Pcuchar]([]),
0
)
client.x = client.oldX
client.y = client.oldY
client.width = client.oldWidth
client.height = client.oldHeight
client.borderWidth = client.oldBorderWidth
client.adjustToState(this.display)
else:
# Don't invoke client.adjustToState here,
# since we want to be able to return the client to its normal state
# when/if this proc is invoked again.
discard XSetWindowBorderWidth(this.display, client.window, 0)
discard XMoveResizeWindow(
this.display,
client.window,
this.area.x,
this.area.y,
this.area.width.cuint,
this.area.height.cuint
)
var arr = [$NetWMStateFullScreen]
discard XChangeProperty(
this.display,
Expand All @@ -479,6 +472,18 @@ proc toggleFullscreen*(this: Monitor, client: var Client) =
cast[Pcuchar](arr.addr),
1
)
client.oldX = client.x
client.oldY = client.y
client.oldWidth = client.width
client.oldHeight = client.height
client.oldBorderWidth = client.borderWidth

client.x = this.area.x
client.y = this.area.y
client.width = this.area.width
client.height = this.area.height
client.borderWidth = 0
client.adjustToState(this.display)
discard XRaiseWindow(this.display, client.window)

client.isFullscreen = not client.isFullscreen
Expand Down
8 changes: 5 additions & 3 deletions src/nimdowpkg/windowmanager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ proc onConfigureRequest(this: WindowManager, e: XConfigureRequestEvent) =
client.width.cint,
client.height.cint
)
# TODO: Is this needed?
this.selectedMonitor.doLayout()
else:
this.configure(client)
Expand Down Expand Up @@ -579,6 +578,8 @@ proc manage(this: WindowManager, window: Window, windowAttr: XWindowAttributes)
client.height = windowAttr.height.uint

discard XSetWindowBorder(this.display, window, this.windowSettings.borderColorUnfocused)

this.configure(client)

discard XSelectInput(this.display,
window,
Expand All @@ -590,15 +591,16 @@ proc manage(this: WindowManager, window: Window, windowAttr: XWindowAttributes)

this.selectedMonitor.addWindowToClientListProperty(window)

this.updateWindowType(client)
this.updateSizeHints(client)

discard XMoveResizeWindow(this.display,
window,
client.x,
client.y,
client.width.cuint,
client.height.cuint)

this.updateWindowType(client)
this.updateSizeHints(client)
this.selectedMonitor.doLayout()
discard XMapWindow(this.display, window)

Expand Down

0 comments on commit 1b23711

Please sign in to comment.