Skip to content

Commit

Permalink
Fixed a number of bugs/crashes (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
avahe-kellenberger authored Jun 19, 2020
1 parent 902eae8 commit d002dc3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 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.4"
version = "0.5.5"
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":
quit "Nimdow v0.5.4"
quit "Nimdow v0.5.5"
else:
# If given a parameter for a config file, use it instead of the default.
configLoc = params[0].string
Expand Down
4 changes: 3 additions & 1 deletion src/nimdowpkg/event/xeventmanager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ proc dispatchEvent*(this: XEventManager, e: XEvent) =
# We are not listening for this event type - exit.
if e.theType notin this.listenerMap:
return

let listeners = this.listenerMap[e.theType]
for listener in listeners:
listener(e)
Expand All @@ -40,7 +39,10 @@ proc startEventListenerLoop*(this: XEventManager, display: PDisplay) =
## Infinitely listens for and dispatches libx.TXEvents.
## This proc will not return unless there is an error.

discard XSync(display, false.XBool)
# XNextEvent returns 0 unless there is an error.
while XNextEvent(display, addr(this.event)) == 0:
this.dispatchEvent(this.event)

discard XCloseDisplay(display)

6 changes: 4 additions & 2 deletions src/nimdowpkg/monitor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,11 @@ proc removeWindowFromTagTable*(this: Monitor, window: Window): bool =
this.statusBar.setSelectedClient(nil, false)
this.statusBar.setActiveWindowTitle("")
else:
withSome(this.selectedTag.selectedClient, client):
let opt = this.selectedTag.selectedClient
withSome(opt, client):
this.statusBar.setSelectedClient(client)
withSome(this.display.getWindowName(client.window), title):
let opt = this.display.getWindowName(client.window)
withSome(opt, title):
this.statusBar.setActiveWindowTitle(title)

proc removeWindow*(this: Monitor, window: Window): bool =
Expand Down
9 changes: 6 additions & 3 deletions src/nimdowpkg/windowmanager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,8 @@ proc onConfigureRequest(this: WindowManager, e: XConfigureRequestEvent) =

proc onClientMessage(this: WindowManager, e: XClientMessageEvent) =
for monitor in this.monitors:
withSome(monitor.find(e.window), client):
let opt = monitor.find(e.window)
withSome(opt, client):
if e.message_type == $NetWMState:
let fullscreenAtom = $NetWMStateFullScreen
if e.data.l[1] == fullscreenAtom or
Expand Down Expand Up @@ -685,7 +686,8 @@ proc onPropertyNotify(this: WindowManager, e: XPropertyEvent) =
for monitor in this.monitors:
monitor.withSomeCurrClient(client):
if client.window == e.window:
withSome(this.display.getWindowName(client.window), title):
let opt = this.display.getWindowName(client.window)
withSome(opt, title):
this.selectedMonitor.statusBar.setActiveWindowTitle(title)

proc onExposeNotify(this: WindowManager, e: XExposeEvent) =
Expand Down Expand Up @@ -744,7 +746,8 @@ proc handleButtonReleased(this: WindowManager, e: XButtonEvent) =
nextMonitor.currTagClients.add(client)
nextMonitor.selectedTag.setSelectedClient(client)
nextMonitor.statusBar.setSelectedClient(client)
withSome(this.display.getWindowName(client.window), title):
let opt = this.display.getWindowName(client.window)
withSome(opt, title):
nextMonitor.statusBar.setActiveWindowTitle(title)

this.selectedMonitor = nextMonitor
Expand Down
17 changes: 9 additions & 8 deletions src/nimdowpkg/xatoms.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type
WMName, WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast
NetAtom* = enum
NetActiveWindow, NetSupported,
NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,
# NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,
NetWMName, NetWMState, NetWMStateAbove, NetWMStateSticky,
NetSupportingWMCheck, NetWMStateFullScreen, NetClientList, NetWMStrutPartial,
NetWMWindowType, NetWMWindowTypeNormal, NetWMWindowTypeDialog, NetWMWindowTypeUtility,
Expand All @@ -19,7 +19,8 @@ type
NetWMDesktop, NetDesktopViewport, NetNumberOfDesktops, NetCurrentDesktop, NetDesktopNames,
NetLast
XAtom* = enum
Manager, Xembed, XembedInfo, XLast
Manager, XLast
# Xembed, XembedInfo

var WMAtoms*: array[ord(WMLast), Atom]
var NetAtoms*: array[ord(NetLast), Atom]
Expand Down Expand Up @@ -48,10 +49,10 @@ proc getNetAtoms*(display: PDisplay): array[ord(NetLast), Atom] =
[
XInternAtom(display, "_NET_ACTIVE_WINDOW", false),
XInternAtom(display, "_NET_SUPPORTED", false),
XInternAtom(display, "_NET_SYSTEM_TRAY_S0", false),
XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", false),
XInternAtom(display, "_NET_SYSTEM_TRAY_ORIENTATION", false),
XInternAtom(display, "_NET_SYSTEM_TRAY_ORIENTATION_HORZ", false),
# XInternAtom(display, "_NET_SYSTEM_TRAY_S0", false),
# XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", false),
# XInternAtom(display, "_NET_SYSTEM_TRAY_ORIENTATION", false),
# XInternAtom(display, "_NET_SYSTEM_TRAY_ORIENTATION_HORZ", false),
XInternAtom(display, "_NET_WM_NAME", false),
XInternAtom(display, "_NET_WM_STATE", false),
XInternAtom(display, "_NET_WM_STATE_ABOVE", false),
Expand Down Expand Up @@ -82,8 +83,8 @@ proc getNetAtoms*(display: PDisplay): array[ord(NetLast), Atom] =
proc getXAtoms*(display: PDisplay): array[ord(XLast), Atom] =
[
XInternAtom(display, "MANAGER", false),
XInternAtom(display, "_XEMBED", false),
XInternAtom(display, "_XEMBED_INFO", false)
# XInternAtom(display, "_XEMBED", false),
# XInternAtom(display, "_XEMBED_INFO", false)
]

proc getProperty*[T](
Expand Down

0 comments on commit d002dc3

Please sign in to comment.