From 2986129d34cf82eb752e9651effd882fdb371996 Mon Sep 17 00:00:00 2001 From: slotThe Date: Tue, 27 Apr 2021 10:43:05 +0200 Subject: [PATCH 1/2] Add setClassHint This is an interface for `XSetClassHint()`, the counterpart for the already available `XGetClassHint()`. It is specifically needed inside xmonad-contrib to set the `WM_CLASS` property of certain windows we spawn. Related: - https://github.com/xmonad/xmonad-contrib/issues/526 - https://github.com/xmonad/xmonad-contrib/issues/369 --- Graphics/X11/Xlib/Extras.hsc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Graphics/X11/Xlib/Extras.hsc b/Graphics/X11/Xlib/Extras.hsc index 45586cf..09907e7 100644 --- a/Graphics/X11/Xlib/Extras.hsc +++ b/Graphics/X11/Xlib/Extras.hsc @@ -1515,6 +1515,18 @@ getClassHint d w = allocaBytes (#{size XClassHint}) $ \ p -> do foreign import ccall unsafe "XlibExtras.h XGetClassHint" xGetClassHint :: Display -> Window -> Ptr ClassHint -> IO Status +-- | Set the @WM_CLASS@ property for the given window. +setClassHint :: Display -> Window -> ClassHint -> IO () +setClassHint dpy win (ClassHint name cl) = + allocaBytes (#{size XClassHint}) $ \ptr -> do + withCString name $ \c_name -> withCString cl $ \c_cl -> do + #{poke XClassHint, res_name } ptr c_name + #{poke XClassHint, res_class} ptr c_cl + xSetClassHint dpy win ptr + +foreign import ccall unsafe "XlibExtras.h XSetClassHint" + xSetClassHint :: Display -> Window -> Ptr ClassHint -> IO () + ------------------------------------------------------------------------ -- WM Hints From ba1c0b920650fa55d31a70d5485ce7aca00b3eaf Mon Sep 17 00:00:00 2001 From: slotThe Date: Wed, 28 Apr 2021 09:39:29 +0200 Subject: [PATCH 2/2] Update CHANGES.md: Add setClassHint --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 9eddf09..ad5b65f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,8 @@ * Added `xrrGetMonitors` and `XRRMonitorInfo` (#42) + * Added `setClassHint` (#76) + ## 1.9.2 (2020-08-25) * Make sure that X11 search paths determined by autoconf are actually passed