Use atomic window props in window manage hook

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Use atomic window props in window manage hook

Chris Bell
Hi, all

I was wondering, how could I set a window to float based on its atomic
window properties? I'm running Xmonad raw on top of X on Fedora 20; no DE.
According to xprop, the only 'special' property of this window is:

_NET_WM_STATE(ATOM) = _NET_WM_STATE_ABOVE, _NET_WM_STATE_STICKY

particularly the STATE_ABOVE property. So far, I haven't found a reliable
way to extract and check if this property exists is set within a mange
hook. I've tried pulling the entire property as a stringProperty - and
later as an atomic using getAtom - and looking for my string with IsInfixOf
(but I think that was pretty misguided, since it wouldn't compile), and
I've tried checking against:

( isInProperty "_NET_WM_STATE" "_NET_WM_STATE_ABOVE" )

and have also tried it with "_NET_WM_STATE(ATOM)". I don't get any compile
errors, but... it doesn't automatically  float the windows, either. I
apologize if it's something simple I'm overlooking - I've found the Haskell
difficulty curve to be more extreme than any other language I've worked
with. With the possible exception of Matlab.

The window is one of those fancy special new "panel" not-windows that
Chrome is implementing; it's for the Hangouts extension with 'enable
panels' turned on in chrome://flags/#enable-panels. They're frustrating,
because Chrome can actually handle them as dockable internal window,
docking them at the bottom of the browser. Or it can be handled by the OS
WM. All of the window properties are identical to a normal Chrome window,
except the STATE_ABOVE flag, so that's all I can think to use.

Any suggestions are more than welcome.

Regards,

Chris Bell

Ph.D. Candidate, Teaching Assistant, Gentleman, Scholar, Penguin Wrangler
University of South Florida
College of Engineering
Department of Computer Science and Engineering
NarMOS Research Team, Official Daemon Charmer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20141211/5ee3dc71/attachment.html>

Reply | Threaded
Open this post in threaded view
|

Use atomic window props in window manage hook

Eric Mrak
This is what I use for checking for _NET_WM_WINDOW_TYPE_DIALOG atoms:

import Foreign.C.Types (CLong)

checkDialog :: Query Bool
checkDialog = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DIALOG"

checkAtom :: String -> String -> Query Bool
checkAtom name value = ask >>= \w -> liftX $ do
                a <- getAtom name
                val <- getAtom value
                mbr <- getProp w a
                case mbr of
                  Just [r] -> return $ elem (fromIntegral r) [val]
                  _ -> return False

-- | Helper to read a property
getProp :: Window -> Atom -> X (Maybe [CLong])
getProp w a = withDisplay $ \dpy -> io $ getWindowProperty32 dpy a w

You would probably change checkDialog to use checkAtom "_NET_WM_STATE"
"_NET_WM_STATE_ABOVE"
I would credit the original author I stole this from, but I can't seem to
find it again.

Hope this helps and isn't simply reproducing what you've already tried :)

On Thu, Dec 11, 2014 at 11:21 AM, Chris Bell <cwbell at mail.usf.edu> wrote:

> Hi, all
>
> I was wondering, how could I set a window to float based on its atomic
> window properties? I'm running Xmonad raw on top of X on Fedora 20; no DE.
> According to xprop, the only 'special' property of this window is:
>
> _NET_WM_STATE(ATOM) = _NET_WM_STATE_ABOVE, _NET_WM_STATE_STICKY
>
> particularly the STATE_ABOVE property. So far, I haven't found a reliable
> way to extract and check if this property exists is set within a mange
> hook. I've tried pulling the entire property as a stringProperty - and
> later as an atomic using getAtom - and looking for my string with IsInfixOf
> (but I think that was pretty misguided, since it wouldn't compile), and
> I've tried checking against:
>
> ( isInProperty "_NET_WM_STATE" "_NET_WM_STATE_ABOVE" )
>
> and have also tried it with "_NET_WM_STATE(ATOM)". I don't get any compile
> errors, but... it doesn't automatically  float the windows, either. I
> apologize if it's something simple I'm overlooking - I've found the Haskell
> difficulty curve to be more extreme than any other language I've worked
> with. With the possible exception of Matlab.
>
> The window is one of those fancy special new "panel" not-windows that
> Chrome is implementing; it's for the Hangouts extension with 'enable
> panels' turned on in chrome://flags/#enable-panels. They're frustrating,
> because Chrome can actually handle them as dockable internal window,
> docking them at the bottom of the browser. Or it can be handled by the OS
> WM. All of the window properties are identical to a normal Chrome window,
> except the STATE_ABOVE flag, so that's all I can think to use.
>
> Any suggestions are more than welcome.
>
> Regards,
>
> Chris Bell
>
> Ph.D. Candidate, Teaching Assistant, Gentleman, Scholar, Penguin Wrangler
> University of South Florida
> College of Engineering
> Department of Computer Science and Engineering
> NarMOS Research Team, Official Daemon Charmer
>
> _______________________________________________
> xmonad mailing list
> xmonad at haskell.org
> http://www.haskell.org/mailman/listinfo/xmonad
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20141211/a2564d08/attachment.html>

Reply | Threaded
Open this post in threaded view
|

Use atomic window props in window manage hook

Brandon Allbery
In reply to this post by Chris Bell
On Thu, Dec 11, 2014 at 12:21 PM, Chris Bell <cwbell at mail.usf.edu> wrote:

> (but I think that was pretty misguided, since it wouldn't compile), and
> I've tried checking against:
>

> ( isInProperty "_NET_WM_STATE" "_NET_WM_STATE_ABOVE" )
>

This is the correct way to do it, if it is set at map time. But it might
not be, in which case you need a handleEventHook looking for a
_NET_WM_STATE ClientMessage. And Chrome does have a certain annoying
history of not setting various window properties until after the window is
mapped.

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20141211/25c5bf97/attachment.html>

Reply | Threaded
Open this post in threaded view
|

Use atomic window props in window manage hook

Brandon Allbery
In reply to this post by Eric Mrak
On Thu, Dec 11, 2014 at 12:53 PM, Eric Mrak <mail at ericmrak.info> wrote:

> This is what I use for checking for _NET_WM_WINDOW_TYPE_DIALOG atoms:
>

You have reinvented XMonad.Hooks.ManageHelpers.isDialog.

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20141211/3d238a95/attachment.html>

Reply | Threaded
Open this post in threaded view
|

Use atomic window props in window manage hook

Chris Bell
In reply to this post by Brandon Allbery
On Thu, Dec 11, 2014 at 12:55 PM, Brandon Allbery <allbery.b at gmail.com> wrote:
> This is the correct way to do it, if it is set at map time.

Aha, thanks. It turns out my code had a typo (extra underscore), but I
didn't notice it because I wasn't sure I was even taking the correct
approach.

> And Chrome does have a certain annoying history of not
> setting various window properties until after the window is mapped.

I know... I've dedicated a sizable chunk of my xmonad.hs just to
handling Chrome's various special cases.

Chris Bell

Ph.D. Candidate, Teaching Assistant, Gentleman, Scholar, Penguin Wrangler
University of South Florida
College of Engineering
Department of Computer Science and Engineering
NarMOS Research Team, Official Daemon Charmer