place-cursor-at 1.0.0 → 1.0.1
raw patch · 3 files changed
+31/−32 lines, 3 files
Files
- CHANGELOG.md +13/−0
- place-cursor-at.cabal +4/−3
- src/place-cursor-at.hs +14/−29
+ CHANGELOG.md view
@@ -0,0 +1,13 @@+# Change Log / Release Notes++## 1.0.1 (March 20, 2021)++### Bug Fixes++- Fix failing on killing previous application instance++ https://github.com/unclechu/place-cursor-at/issues/4++## 1.0.0 (March 20, 2021)++- First stable release
place-cursor-at.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 66d39f7b6b91273a09289c622d5c81b8bb6f010ee69d032997ed77412a1f96f5+-- hash: 28a469787c7689160b683cbbdb65c1e82d866a1631cfe3a311b51a2ff5c70c49 name: place-cursor-at-version: 1.0.0+version: 1.0.1 synopsis: A utility for X11 that moves the mouse cursor using the keyboard category: Utility, GUI, Desktop, Desktop Environment, X11 homepage: https://github.com/unclechu/place-cursor-at#readme@@ -17,10 +17,11 @@ copyright: Copyright © 2017–2021 Viacheslav Lotsmanov license: GPL-3 license-file: LICENSE-tested-with: GHC ==8.10.4 || ==8.8.4 || ==8.6.4+tested-with: GHC == 8.10.4 || == 8.8.4 || == 8.6.4 build-type: Simple extra-source-files: README.md+ CHANGELOG.md source-repository head type: git
src/place-cursor-at.hs view
@@ -13,8 +13,8 @@ import Data.Bifunctor (first) import Data.Bits ((.|.))-import Data.Bool (bool) import Data.Char (toUpper)+import Data.Function (fix) import Data.Functor ((<&>)) import Data.List (find) import Numeric.Natural@@ -241,38 +241,23 @@ waitBeforeItIsDone doneHandler >>= either throwIO pure --- | Kill previous instance of *place-cursor-at*.------ FIXME In some cases it fails the killer with this exception in the log:------ @--- X Error of failed request: BadValue (integer parameter out of range for operation)--- Major opcode of failed request: 113 (X_KillClient)--- Value in failed request: 0x6000002--- Serial number of failed request: 259--- Current serial number in output stream: 260--- @------ I have no idea what the heck is this. I tried many ways to fix this with no success.+-- | Kill previous instance of *place-cursor-at* killPreviousInstanceIfExists ∷ Display → IO () killPreviousInstanceIfExists dpy = go where- go = traverseChildWindows (defaultRootWindow dpy)- kill = killClient dpy-- traverseChildWindows ∷ Window → IO ()- traverseChildWindows wnd = killEmRecursively where- killEmRecursively =- getAllWindowsList wnd- >>= foldM reducer mempty- >>= (mapM_ kill *** mapM_ traverseChildWindows) • uncurry (>>)+ go = findPreyToKill (defaultRootWindow dpy) >>= mapM_ (killClient dpy) - reducer ∷ acc ~ ([Window], [Window]) ⇒ acc → Window → IO acc- reducer acc x = f where- f = isPlaceCursorAtWindow x <&> \is → (x `appendIf` is *** x `appendIf` not is) acc- appendIf wndToAppend = bool id (⧺ [wndToAppend])+ findPreyToKill ∷ Window → IO [Window]+ findPreyToKill =+ ($ []) $ fix $ \again acc !wnd →+ isPlaceCursorAtWindow wnd >>= \case+ False → foldM again acc =<< getChildWindows wnd+ True → slurpAllChildren acc wnd+ where+ slurpAllChildren acc !wnd =+ foldM slurpAllChildren (wnd : acc) =<< getChildWindows wnd - getAllWindowsList ∷ Window → IO [Window]- getAllWindowsList wnd = queryTree dpy wnd <&> \(_, _, x) → x+ getChildWindows ∷ Window → IO [Window]+ getChildWindows wnd = queryTree dpy wnd <&> \(_, _, x) → x isPlaceCursorAtWindow ∷ Window → IO Bool isPlaceCursorAtWindow wnd = x where