Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invisible window tiled after closing discord #223

Closed
beaumccartney opened this issue Jun 22, 2022 · 10 comments
Closed

Invisible window tiled after closing discord #223

beaumccartney opened this issue Jun 22, 2022 · 10 comments
Labels
bug Something isn't working

Comments

@beaumccartney
Copy link
Contributor

beaumccartney commented Jun 22, 2022

Describe the bug

After closing a discord window, tiling behaves as if there's still a window, though its invisible.

The invisible window can be cycled to, gets a border, and makes my bar (default polybar) say "Discord" when I hover it.

Killing all discord processes makes this "invisible window" go away.

Not killing discord (for notifications and the like) would be preferable.

EDIT: This happens for any window that you close without killing the process. In summary, a window is tiled until its backing process dies (I think).

To Reproduce

Steps to reproduce the behavior:

  1. Log in to penrose with side_stack layout
  2. Open a terminal and discord client window
  3. Close the discord client window
  4. Terminal window still tiled next to an invisible window - adding more terminals (or other windows) shows much the same

Expected behavior

No invisible window messing with the tiling.

Screenshots

Before closing discord window
temp

After closing discord window
temp0

After running pkill Discord
temp1

Versions & OS Details

  • OS: linux
  • Distribution: Arch
  • Version: Linux 5.18.5-zen1-1-zen with nvidia-open-dkms (latest version, updated five mins before this writing)
  • Penrose Version: 21c708f (most recent development commit at the time of writing)

Additional context

// main.rs
#[macro_use]
extern crate penrose;

use penrose::{
    core::{
        // bindings::KeyEventHandler,
        config::Config,
        helpers::index_selectors,
        // manager::WindowManager,
        layout::{side_stack, monocle, Layout, LayoutConf}
    },
    logging_error_handler,
    xcb::new_xcb_backed_window_manager,
    Backward, Forward, Less, More, Selector
};

// imports from lib.rs
use penrose_config::*;

use simplelog::{LevelFilter, SimpleLogger};

fn main() -> penrose::Result<()> {
    // Initialise the logger (use LevelFilter::Debug to enable debug logging)
    if let Err(e) = SimpleLogger::init(LevelFilter::Info, simplelog::Config::default()) {
        panic!("unable to set log level: {}", e);
    };
    
    // run startup script
    spawn!("/home/beaum/.config/startup.sh")?;

    let config = Config::default()
        .builder()
        .workspaces(["1", "2", "3", "4", "5", "6", "7", "8", "9"])
        .layouts(vec![
            Layout::new(TILE_SYMBOL, LayoutConf::default(), side_stack, N_MAIN, RATIO),
            Layout::new(MONO_SYMBOL, LayoutConf::default(), monocle, N_MAIN, RATIO),
            Layout::floating(FLOAT_SYMBOL),
        ])
        .show_bar(true)
        .bar_height(40)
        .build()
        .expect("built config successfully");
    
    let key_bindings = gen_keybindings! {
        "M-semicolon" => run_external!(LAUNCHER);
        "M-Return" => run_external!(TERMINAL);
        
        // Exit Penrose (important to remember this one!)
        "M-S-Q" => run_internal!(exit);

        // client management
        "M-j" => run_internal!(cycle_client, Forward);
        "M-k" => run_internal!(cycle_client, Backward);
        "M-S-j" => run_internal!(drag_client, Forward);
        "M-S-k" => run_internal!(drag_client, Backward);
        "M-f" => run_internal!(toggle_client_fullscreen, &Selector::Focused);
        "M-q" => run_internal!(kill_client);
        
        // screen cycle
        "M-h" => run_internal!(cycle_screen, Backward);
        "M-l" => run_internal!(cycle_screen, Forward);

        // workspace management
        "M-Tab" => run_internal!(toggle_workspace);
        "M-period" => run_internal!(cycle_workspace, Forward);
        "M-comma" => run_internal!(cycle_workspace, Backward);

        // Layout management
        // TODO: pick specific layout keybinds
        "M-grave" => run_internal!(cycle_layout, Forward);
        "M-S-grave" => run_internal!(cycle_layout, Backward);
        "M-i" => run_internal!(update_max_main, More);
        "M-d" => run_internal!(update_max_main, Less);
        "M-S-h" => run_internal!(update_main_ratio, More);
        "M-S-l" => run_internal!(update_main_ratio, Less);

        map: { "1", "2", "3", "4", "5", "6", "7", "8", "9" } to index_selectors(9) => {
            "M-{}" => focus_workspace (REF);
            "M-S-{}" => client_to_workspace (REF);
        };
    };

    let mut wm = new_xcb_backed_window_manager(config, vec![], logging_error_handler())?;
    wm.grab_keys_and_run(key_bindings, map!{})
}
// lib.rs
// configuration constants
pub const TERMINAL: &str = env!("TERMINAL");
pub const LAUNCHER: &str = "dmenu_run";
pub const N_MAIN: u32 = 1;
pub const RATIO: f32 = 0.6;

// layout symbols
pub const TILE_SYMBOL: &str = "[tile]";
pub const MONO_SYMBOL: &str = "[mono]";
pub const FLOAT_SYMBOL: &str = "[----]";

My .xinitrc (please note that I have dash symlinked to /bin/sh - still POSIX compliant tho)

#/bin/sh
#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then

    xrdb -merge $sysresources

fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then


    xrdb -merge "$userresources"

fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

nvidia-settings --load-config-only # load brightness settings

discord --start-minimized &

# execute the debug build of my penrose config
# the suggested syntax of &> isn't actually posix compliant afaik so that's why i'm doing stdout and stderr seperately
exec "$SOURCE_INSTALLS"/penrose_config/target/debug/penrose_config 2> /tmp/penrose.log 1> /tmp/penrose.log

Output of cat /tmp/penrose.log:

18:53:27 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:27 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:28 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:28 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:31 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:31 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:31 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:31 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:44 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:44 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:44 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:44 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:47 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:53:47 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:54:37 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:54:37 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:54:37 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:54:37 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:55:26 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:55:26 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:55:26 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:55:26 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:55:32 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:55:32 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:55:32 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:55:32 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:57:26 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:57:26 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:57:26 [ERROR] error=xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
18:57:26 [ERROR] xcb::ReplyError: xcb::Error { response_type: 0, error_code: 3 }
@beaumccartney beaumccartney added the bug Something isn't working label Jun 22, 2022
@sminez
Copy link
Owner

sminez commented Oct 29, 2022

If you are up for trying this out with the new 0.3 API that's on develop I'd appreciate knowing how it now behaves 🙂

There are some helper actions you can run to dump additional state into the log file which should help with tracking down what's going on if it's still misbehaving

@yohannd1
Copy link

My main guess is that the window is minimized, in some way. Might not be that, but I just tested minimizing a window and it also became an invisible window.

I also have been experiencing picom (compositor) appearing as an invisible window too.

@sminez
Copy link
Owner

sminez commented Nov 13, 2022

Is that using the new 0.3 release?

@yohannd1
Copy link

I believe it is (I'm kinda lost at the moment) - here's penrose entries on Cargo.lock:

[[package]]
name = "penrose"
version = "0.3.0"
source = "git+https://github.com/sminez/penrose?branch=develop#e7d01bd1ad9219b006c77d1043b47a9a246c55f4"
dependencies = [
 "anymap",
 "bitflags",
 "nix 0.25.0",
 "penrose_keysyms",
 "strum",
 "strum_macros",
 "thiserror",
 "tracing",
 "x11rb",
]

[[package]]
name = "penrose_keysyms"
version = "0.1.1"
source = "git+https://github.com/sminez/penrose?branch=develop#e7d01bd1ad9219b006c77d1043b47a9a246c55f4"
dependencies = [
 "strum",
 "strum_macros",
]

[[package]]
name = "penrose_ui"
version = "0.1.0"
source = "git+https://github.com/sminez/penrose?branch=develop#e7d01bd1ad9219b006c77d1043b47a9a246c55f4"
dependencies = [
 "cairo-rs",
 "pango",
 "pangocairo",
 "penrose",
 "thiserror",
 "tracing",
 "x11rb",
]

@sminez
Copy link
Owner

sminez commented Nov 13, 2022

Ok that definitely looks like it's running the new code, which is surprising because I use picom myself and don't have an issue with it. I raised #244 the other day around the behaviour when penrose is restarted in a persitant session and in that case I do see picom getting tiled as an invisible window.

Are you able to provide a link to your main.rs (either a git repo or gist would be best) so I can try and work out what's going on?

@yohannd1
Copy link

Sure! Here it is: https://github.com/YohananDiamond/pencil

@sminez
Copy link
Owner

sminez commented Nov 13, 2022

I can't see anything in your set up that would lead to picom becoming tiled 😕

Even if I pkill it and start it while Penrose is running it's correctly ignored and I get the compositing without anything becoming tiled.

Are you able to try setting up logging for me and running it at trace level when this behaviour happens? I think I need to see the event handler logs for this to work out what's going on as I'm not able to reproduce it

@yohannd1
Copy link

yohannd1 commented Nov 14, 2022

Here: https://gist.github.com/YohananDiamond/bb15a3dc67f5834fb3404a1e0716a47f

Also, one thing I noticed - the first time I opened penrose today, the problem didn't happen with picom, though there was still an invisible window. I also noticed picom's window is pitch black, not transparent (that was just a rendering leftover of before the wallpaper appeared), and that there were some other windows like picom's.

@sminez
Copy link
Owner

sminez commented Nov 14, 2022

Ah ok, there's this in your logfile: https://gist.github.com/YohananDiamond/bb15a3dc67f5834fb3404a1e0716a47f#file-penrose-error-log-20221114-01-txt-L6-L8

That's the logic I mention in #244 that I know is currently not doing the right thing 😞 If you move whatever startup script you have to be triggered using the SpawnOnStartup hook that should fix it? Though obviously that's a workaround rather than a full fix!

@yohannd1
Copy link

Thanks! That seems to have fixed it, and it's not really much of an issue, so no problem keeping that for now!

Also, a suggestion: maybe the change the type of the prog field (inside SpawnOnStartup) to Rc<String>. I noticed it only accepts &'static str and, in my case, I wanted to get the profile directory dynamically. A Rc<String> probably isn't the best solution but this was a quick solution I found :P

Here's the code (I rewrote startup.rs and put it in my config): https://github.com/YohananDiamond/pencil/blob/a8f4e4dfe201a03cc66b5df56bb5d39e0f90c1f5/src/startup.rs

@sminez sminez closed this as completed Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants