Skip to content

Commit

Permalink
add window rule disable deco
Browse files Browse the repository at this point in the history
  • Loading branch information
codic13 committed Dec 31, 2021
1 parent 49e49d6 commit 279c94b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/atoms.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ type
IpcBorderWidth, IpcFrameActivePixel, IpcFrameInactivePixel, IpcFrameHeight, IpcTextActivePixel, IpcTextInactivePixel,
IpcTextFont, IpcTextOffset, IpcKillClient, IpcCloseClient, IpcSwitchTag, IpcLayout, IpcGaps, IpcMaster, IpcStruts,
IpcMoveTag, IpcFrameLeft, IpcFrameCenter, IpcFrameRight,
IpcFloat, IpcButtonOffset, IpcButtonSize, IpcRootMenu, IpcClosePath, IpcMaximizePath, IpcMaximizeClient
IpcFloat, IpcButtonOffset, IpcButtonSize, IpcRootMenu, IpcClosePath, IpcMaximizePath, IpcMaximizeClient,
IpcDecorationDisable

func getNetAtoms*(dpy: ptr Display): array[NetAtom, Atom] =
[
Expand Down Expand Up @@ -92,5 +93,6 @@ func getIpcAtoms*(dpy: ptr Display): array[IpcAtom, Atom] =
dpy.XInternAtom("WORM_IPC_ROOT_MENU", false),
dpy.XInternAtom("WORM_IPC_CLOSE_PATH", false),
dpy.XInternAtom("WORM_IPC_MAXIMIZE_PATH", false),
dpy.XInternAtom("WORM_IPC_MAXIMIZE_CLIENT", false)
dpy.XInternAtom("WORM_IPC_MAXIMIZE_CLIENT", false),
dpy.XInternAtom("WORM_IPC_DECORATION_DISABLE", false)
]
18 changes: 16 additions & 2 deletions src/events/clientmessage.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ../wm, ../atoms, ../types, ../log
import x11/[xlib, x, xinerama, xatom, xft, xutil]
import std/[options, strutils]
import regex

proc handleClientMessage*(self: var Wm; ev: XClientMessageEvent): void =
if ev.messageType == self.netAtoms[NetWMState]:
Expand Down Expand Up @@ -514,7 +515,7 @@ proc handleClientMessage*(self: var Wm; ev: XClientMessageEvent): void =
IpcClosePath])
let err = self.dpy.XmbTextPropertyToTextList(addr fontProp, cast[
ptr ptr cstring](addr fontList), addr n)
log "Changing root menu path to " & $fontList[0]
log "Changing close path to " & $fontList[0]
self.config.closePath = $fontList[0]
if err >= Success and n > 0 and fontList != nil and fontList[0] != nil:
XFreeStringList cast[ptr cstring](fontList)
Expand All @@ -527,8 +528,21 @@ proc handleClientMessage*(self: var Wm; ev: XClientMessageEvent): void =
IpcMaximizePath])
let err = self.dpy.XmbTextPropertyToTextList(addr fontProp, cast[
ptr ptr cstring](addr fontList), addr n)
log "Changing root menu path to " & $fontList[0]
log "Changing maximize path to " & $fontList[0]
self.config.maximizePath = $fontList[0]
if err >= Success and n > 0 and fontList != nil and fontList[0] != nil:
XFreeStringList cast[ptr cstring](fontList)
discard XFree fontProp.value
elif ev.data.l[0] == clong self.ipcAtoms[IpcDecorationDisable]:
var fontProp: XTextProperty
var fontList: ptr UncheckedArray[cstring]
var n: cint
discard self.dpy.XGetTextProperty(self.root, addr fontProp, self.ipcAtoms[
IpcDecorationDisable])
let err = self.dpy.XmbTextPropertyToTextList(addr fontProp, cast[
ptr ptr cstring](addr fontList), addr n)
log "Appending to decoration disable list: " & $fontList[0]
self.noDecorList.add re $fontList[0]
if err >= Success and n > 0 and fontList != nil and fontList[0] != nil:
XFreeStringList cast[ptr cstring](fontList)
discard XFree fontProp.value
15 changes: 13 additions & 2 deletions src/events/maprequest.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ../wm, ../types, ../atoms, ../log
import std/[options, strutils]
import x11/[x, xlib, xft, xatom]
import x11/[x, xlib, xft, xatom, xutil]
import regex

func getProperty[T](
dpy: ptr Display;
Expand Down Expand Up @@ -53,6 +54,16 @@ proc handleMapRequest*(self: var Wm; ev: XMapRequestEvent): void =
if hints.isSome and hints.get.flags == 2 and hints.get.decorations == 0:
frameHeight = 0
csd = true
var chr: XClassHint
discard self.dpy.XGetClassHint(ev.window, addr chr)
block:
for thing in self.noDecorList:
var m: RegexMatch
log $chr.resClass
log $thing
if ($chr.resClass).match thing:
csd = true
frameHeight = 0
var frameAttr = XSetWindowAttributes(backgroundPixel: culong self.config.frameActivePixel,
borderPixel: self.config.borderActivePixel, colormap: attr.colormap)
let frame = self.dpy.XCreateWindow(self.root, attr.x + self.config.struts.left.cint, attr.y + self.config.struts.top.cint,
Expand Down Expand Up @@ -121,7 +132,7 @@ proc handleMapRequest*(self: var Wm; ev: XMapRequestEvent): void =
GrabModeSync, GrabModeSync, None, None)
self.clients.add Client(window: ev.window, frame: Frame(window: frame,
top: top, close: close, maximize: maximize, title: titleWin), draw: draw, color: color,
title: $title, tags: self.tags, floating: self.layout == lyFloating, frameHeight: frameHeight, csd: csd)
title: $title, tags: self.tags, floating: self.layout == lyFloating, frameHeight: frameHeight, csd: csd, class: $chr.resClass)
self.updateClientList
let extents = [self.config.borderWidth, self.config.borderWidth,
self.config.borderWidth+self.config.frameHeight, self.config.borderWidth]
Expand Down
1 change: 1 addition & 0 deletions src/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type
tags*: TagSet
frameHeight*: uint
csd*: bool
class*: string
Config* = object
borderActivePixel*, borderInactivePixel*, borderWidth*: uint
frameActivePixel*, frameInactivePixel*, frameHeight*: uint
Expand Down
4 changes: 3 additions & 1 deletion src/wm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import types
import atoms
import log
import pixie
import regex
# import events/configurerequest

converter toXBool*(x: bool): XBool = x.XBool
Expand All @@ -23,6 +24,7 @@ type
focused*: Option[uint]
tags*: TagSet
layout*: Layout
noDecorList*: seq[Regex]

# event handlers
# proc handleButtonPress(self: var Wm; ev: XButtonEvent): void
Expand Down Expand Up @@ -133,7 +135,7 @@ proc newWm*: Wm =
textActivePixel: 0xffffff, textInactivePixel: 0x000000, textOffset: (x: uint 10, y: uint 20), gaps: 0, buttonSize: 14,
struts: (top: uint 10, bottom: uint 40, left: uint 10,
right: uint 10)), tags: defaultTagSet(),
layout: lyFloating) # The default configuration is reasonably sane, and for now based on the Iceberg colorscheme. It may be changed later; it's recommended for users to write their own.
layout: lyFloating, noDecorList: @[]) # The default configuration is reasonably sane, and for now based on the Iceberg colorscheme. It may be changed later; it's recommended for users to write their own.

func findClient*(self: var Wm; predicate: proc(client: Client): bool): Option[(
ptr Client, uint)] =
Expand Down
8 changes: 8 additions & 0 deletions src/wormc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ proc main: void =
dpy.XSetTextProperty(root, addr fontProp, ipcAtoms[IpcMaximizePath])
discard XFree fontProp.value
data = [clong ipcAtoms[IpcMaximizePath], 0, 0, 0, 0]
of "decoration-disable": # Ditto
var fontList = cstring params[i+1]
var fontProp: XTextProperty
discard dpy.XUtf8TextListToTextProperty(addr fontList, 1,
XUTF8StringStyle, addr fontProp)
dpy.XSetTextProperty(root, addr fontProp, ipcAtoms[IpcDecorationDisable])
discard XFree fontProp.value
data = [clong ipcAtoms[IpcDecorationDisable], 0, 0, 0, 0]
of "text-offset": data = [clong ipcAtoms[IpcTextOffset],
clong params[i+1].parseInt, clong params[i+2].parseInt, 0, 0]
of "kill-client": data = [clong ipcAtoms[IpcKillClient], clong params[
Expand Down
3 changes: 2 additions & 1 deletion worm.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ bin = @["worm", "wormc"]
requires "nim >= 1.4.0"
requires "x11"
# requires "cairo" # disgusting
requires "pixie"
requires "pixie" # chad native Nim drawing library. lets go!
requires "regex"

0 comments on commit 279c94b

Please sign in to comment.