contour-terminal / contour

Modern C++ Terminal Emulator
http://contour-terminal.org/
Apache License 2.0
2.44k stars 107 forks source link

XGetWindowProperty[_NET_ACTIVE_WINDOW] failed (code=1) #773

Closed adgai19 closed 2 years ago

adgai19 commented 2 years ago

Contour Terminal version

Contour Terminal Emulator 0.3.3-unreleased-master-4cb0bf33

Installer source

Github: source code cloned

Operating System

Ubuntu 22.04.1 LTS x86_64

Architecture

x86-64

Other Software

No response

Steps to reproduce

  1. Start contour

Expected Behavior

Display terminal screen without any issues

Actual Behavior

XGetWindowProperty[_NET_ACTIVE_WINDOW] failed (code=1)
xdo_get_active_window reported an error
There are no windows in the stack
Invalid window '%1'
Usage: getwindowpid [window=%1]
If no window is given, %1 is used. See WINDOW STACK in xdotool(1)

before shell prompt. https://user-images.githubusercontent.com/29275245/183113386-d655c479-cf88-416e-8823-e0ada7e2a387.mp4

Additional notes

This issue is present only when I start a new instance of contour(when no other instance is running) from dmenu or rofi. It is not started when I start another instance and contour is already running.

Utkarsh-khambra commented 2 years ago

What window manager are you using?

I am asking since contour doesn't really call anything related to xdotool.

adgai19 commented 2 years ago

This seems to look like it happens only when xdotool is present.

christianparpart commented 2 years ago

Can it be something in your shell init scripts? (bashrc/zshrc)? Please try renaming them temporarily just for the sake of testing this. Can you still produce the error then?

Utkarsh-khambra commented 2 years ago

Maybe related to this https://github.com/jordansissel/xdotool/issues/194 , I can reproduce the crash but I don't get that same error 😐

christianparpart commented 2 years ago

Maybe related to this jordansissel/xdotool#194 , I can reproduce the crash but I don't get that same error 😐

Awesome catch! I think that might actually be a possibility for the root cause. That is: the error is thrown when the terminal window is not in focus yet, because maybe it's not even constructed nor shown yet (!).

The thing is, the terminal session is spawned as soon as possible (not intentionally, just by design), this implies that the window might not be created nor shown nor visible yet when the .zshrc / .bashrc content is being executed.

This will change though in my QML frontend refactor as there I have to work around some Qt5 bug by artifically delaying shell spawning until a safe point. This might help mitigate the issue above.

Generally speaking, this is not a bug of Contour, it is however the expectation of xdotool, that there is a window in focus (which makes sense, most of the time at least). -- that's my understanding on the whole topic so far at least.

whisperity commented 2 years ago

777 is merged. Did this issue get fixed?

christianparpart commented 2 years ago

@whisperity actually, I think it should.

@adgai19, can you confirm that for you?

adgai19 commented 2 years ago

It did. Sorry for not responding earlier. I haven't had the chance to try the newer builds since I switched to nixos

christianparpart commented 2 years ago

It did. Sorry for not responding earlier. I haven't had the chance to try the newer builds since I switched to nixos

No worries. In case of tweaks required to install-deps.sh, PRs are gladly taken, @adgai19. Cheers ;)