baskerville / bspwm

A tiling window manager based on binary space partitioning
BSD 2-Clause "Simplified" License
7.69k stars 417 forks source link

Making panel on top of all windows except fullscreen #484

Open jamietanna opened 8 years ago

jamietanna commented 8 years ago

I'm currently using the following code inside my panel, which is the same as found in bspwm/examples/panel/panel.

panel_bar < "$PANEL_FIFO" | lemonbar -n "$PANEL_WM_NAME" -g x$PANEL_HEIGHT -f "$PANEL_FONT_FAMILY" -F "$(bar_color_fg COLOR_BAR)" -B "$(bar_color_bg COLOR_BAR)" | while read line; do
    eval "$line"
done

wid=$(xdo id -a "$PANEL_WM_NAME")
tries_left=20
while [ -z "$wid" -a "$tries_left" -gt 0 ] ; do
    sleep 0.05
    wid=$(xdo id -a "$PANEL_WM_NAME")
    tries_left=$((tries_left - 1))
done
[ -n "$wid" ] && xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" "$wid"

However, I'm finding that other applications, when fullscreened, remain underneath the panel: 2016-05-18-151435_508x85_scrot

I have found a workaround that lowers the panel once, to just below a fullscreen screen:

if [ -n "$wid" ]; then
    xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" "$wid"
    xdo lower "$wid"
fi

However, this issue does not work when using multiple monitors; on the second monitor, the rule is not applied:

2016-05-18-152001_527x136_scrot

Could this be a bug in https://github.com/baskerville/xdo, or is it more likely me doing something wrong?

baskerville commented 8 years ago

I don't see any issue regarding bspwm here.

jamietanna commented 8 years ago

Apologies, I raised it here due to it being based off your example scripts. Would you recommend this being raised in https://github.com/baskerville/xdo instead, or maybe https://github.com/lemonboy/bar?

baskerville commented 8 years ago

This:

if [ -n "$wid" ]; then
    xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" "$wid"
    xdo lower "$wid"
fi

is equivalent to:

if [ -n "$wid" ]; then
      xdo lower "$wid"
fi

And it should work fine if focus_follows_pointer isn't set (otherwise the windows that represent monitors will capture the pointer events and prevent the panels from receiving them).

Could you post your panel script?

jamietanna commented 8 years ago

Thanks, I've amended that in my panel script. See https://gist.github.com/jamietanna/1b12dbf568a36e1db7afd2fcb67b8f9e for my current configs.

Unfortunately setting focus_follows_pointer to false does not seem to work. With that unset, I still get a fullscreen window on Monitor 1, but not on Monitor 2.

Steps to reproduce:

  1. Fullscreen any window on monitor 1.
  2. Fullscreen terminal window on monitor 2.
  3. In terminal window, run: bspc config focus_follows_pointer false; sleep 5; panel
  4. Switch from monitor 2 to monitor 1.
baskerville commented 8 years ago

What's the content of your bspwmrc?

Can you provide reproduce steps that:

{
    "monitors":
    [
        {
            "name": "ALPHA",
            "rectangle": {"width": 960, "height": 1080, "x": 0, "y": 0}
        },
        {
            "name": "BETA",
            "rectangle": {"width": 960, "height": 1080, "x": 960, "y": 0}
        }
    ]
}
#! /bin/sh

name=bspwm_panel

echo hello | lemonbar -n "$name" -p &

sleep 1 
ref=$(xdo id -N Bspwm -n root | sort | head -n 1)
wid=$(xdo id -a "$name")
echo "ref: ${ref}, wid: ${wid}"
xdo above -t "$ref" "$wid"

?

jamietanna commented 8 years ago

I can confirm that those steps do work, and I get expected behaviour.

My bspwmrc can be found in the updated Gist.

I have also found that the above seems to work regardless of the setting of focus_follows_pointer.

jamietanna commented 8 years ago

Hey @baskerville, any further thoughts on this?

baskerville commented 8 years ago

I'm afraid I won't be able to go further without minimal reproduce steps.

jamietanna commented 8 years ago

Apologies, I misinterpreted your previous message - I will work on providing the steps to reproduce the issue.

phisch commented 8 years ago

There has been a bug in lemonbar which failed rendering the lemonbar behind fullscreen windows on any monitor after the first one. This bug has been fixed in https://github.com/LemonBoy/bar/commit/d680ea4256637bc89d59342cf6ac6c6f5fe62dec.

If you are using the xfc fork, you would have to patch it yourself until the commit has been merged.

Another thing that could be related to your problem, is that xdo id -a NAME can fail to get the process id, since the process takes a few milliseconds to spawn. To prevent this, you can wait until it has been spawned. Although you have already done that, here is how i did it:

echo "demo" | lemonbar -n "BARNAME" -p &

until bar_id=$(xdo id -a BARNAME)
do
  sleep 0.001
done

xdo below -t $(xdo id -n root) $bar_id &

edit: hope this is still of relevance for you