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

bspwm. tdrop opens the application on wrong desktop (bspc-monitor) #369

Closed
peskovdev opened this issue Oct 27, 2022 · 18 comments
Closed

bspwm. tdrop opens the application on wrong desktop (bspc-monitor) #369

peskovdev opened this issue Oct 27, 2022 · 18 comments

Comments

@peskovdev
Copy link
Contributor

peskovdev commented Oct 27, 2022

In order to reproduce this bug, do the following:

  1. Twice execute (open & close) on particular bspc-monitor: tdrop -am -h 60% -w 50% -y 25 -x 25% app
  2. Change bspc-monitor
  3. Execute tdrop -am -h 60% -w 50% -y 25 -x 25% app again for opening on NEW monitor
  4. You will be thrown to the previous monitor, and app will be open there

You can see example here

@peskovdev
Copy link
Contributor Author

I think there should be the following logic:

  1. if we are on the desktop on which the application is open - it must be closed
  2. if we are on a desktop on which the application is not open - it must either be opened (if it wasn't created), or moved to the new desktop (from previous)

Now, when you close the window, tdrop remembers the desktop number and tries to open the application THERE the next time you call it. Why?

@peskovdev
Copy link
Contributor Author

peskovdev commented Nov 6, 2022

image
I found decision: you should to delete or comment 457 line of script. Also i forked and you can just take script from this repo: https://github.com/devpeskov/tdrop

Author said about this: "windowmap does not activate for all window managers"
But in my case, without this line - everything is OK. Perhaps the author added this option to make tdrop work on little-known wm. But it broke script on bspwm.

@peskovdev peskovdev reopened this Nov 7, 2022
peskovdev added a commit to peskovdev/tdrop that referenced this issue Nov 7, 2022
@peskovdev
Copy link
Contributor Author

I created a pull request for fix this: #370

@peskovdev peskovdev changed the title tdrop opens the application on the wrong bspc-monitor tdrop opens the application on the wrong desktop (bspc-monitor) Nov 7, 2022
@peskovdev peskovdev changed the title tdrop opens the application on the wrong desktop (bspc-monitor) bspwm. tdrop opens the application on the wrong desktop (bspc-monitor) Nov 7, 2022
@peskovdev peskovdev changed the title bspwm. tdrop opens the application on the wrong desktop (bspc-monitor) bspwm. tdrop opens the application on wrong desktop (bspc-monitor) Nov 7, 2022
@noctuid
Copy link
Owner

noctuid commented Nov 8, 2022

I will investigate if there is some more generic solution. If not, I will merge your PR. Thanks!

@peskovdev
Copy link
Contributor Author

Hi! How’s the progress with the solution? I would be glad to merge my PR. Thanks!

@noctuid
Copy link
Owner

noctuid commented Mar 3, 2023

Ping me in a week again if I haven't looked into it yet.

@noctuid
Copy link
Owner

noctuid commented Mar 11, 2023

But in my case, without this line - everything is OK. Perhaps the author added this option to make tdrop work on little-known wm. But it broke script on bspwm.

Just for context, I was using bspwm at the time and this was intended to fix this issue for bspwm. I can't reproduce the issue on bspwm 0.9.10. Does it happen every time or inconsistently? Maybe some sleep time is needed for bspwm.

What version of bspwm are you on? If I use #370, it no longer works correctly for me on bspwm (the dropdown shows up but is not focused).

@peskovdev
Copy link
Contributor Author

peskovdev commented Mar 15, 2023

I'm on 0.9.10 version of bspwm.

I added a changed version of tdrop (as in my PR) in ~/.local/bin and since I created PR I've been using it. Indeed, I've noticed that sometimes dropdown isn't focused, but it happens hardly ever, and changing focus is quite easy.

Just now I checked again if tdrop with xdotool windowactivate "$wid" 2> /dev/null-line still opens an application on wrong desktop, and yes, it does.

Does it happen every time or inconsistently?

Every time. If you kill dropdown (process), with next call, it will display correctly. But if you just "hide" dropdown, it will display on desktop where you hided it (not current)

@noctuid
Copy link
Owner

noctuid commented Mar 15, 2023

Does this happen with every program? Are there any steps to reproduce? I tried on multiple desktops and with desktops on multiple monitors but could not reproduce. Could you link me to your config or post it here?

@peskovdev
Copy link
Contributor Author

peskovdev commented Mar 15, 2023

Yes, with every program that i tried.
Steps to reproduce:

1. Twice execute (open & hide) on particular bspc-monitor: `tdrop -am -h 60% -w 50% -y 25 -x 25% app`.
2. Change bspc-monitor.
3. Execute `tdrop -am -h 60% -w 50% -y 25 -x 25% app` again for opening on NEW monitor.
4. You will be thrown to the previous monitor, and app will be open there.

I uploaded video with demonstration on YouTube: https://youtu.be/c-h0TWy8rcQ
In this video I run the next command with hotkey: tdrop -am -h 60% -w 50% -y 25 -x 25% thunderbird -calendar

@peskovdev
Copy link
Contributor Author

Could you link me to your config or post it here?

Yes, of course! I've just published it: https://github.com/peskovdev/dotfiles

@noctuid
Copy link
Owner

noctuid commented Apr 1, 2023

Is your bspwmrc there somewhere (or do you not have one)? I didn't see it. My only guess right now for why this happens for others but not me is some difference in settings.

Also, what does xdotool --version report?

I have a few suggestions you can try:

  1. Add --sync after every windowmap in map_and_reset_geometry, e.g. xdotool windowmap --sync "$wid" 2> /dev/null (this would be the ideal solution if it works).

  2. Try replacing "windowactivate" with "windowfocus"

  3. Try adding sleep time:

# increase sleep time if it still doesn't work
sleep 0.05
xdotool windowactivate "$wid" 2> /dev/null

@peskovdev
Copy link
Contributor Author

I have separated config, so my bspwmrc on another branch. If you would like to see not separated config, it's my friend's config, we tested this bag on his computer, and there are the same problem.

xdotool version: 3.20211022.1

And about suggestions, I'll try this steps a little bit later, ty

@CUexter
Copy link

CUexter commented Sep 29, 2023

is there any update on this issue, i tried @peskovdev fixed but it didnt work for me

tdrop --wm bspwm -ma -h 40% -w -40 -x 20 -y 2% -n dropdown kitty

this is the command i use

I tried adding --sync as @noctuid said after every windowmap and it worked

peskovdev added a commit to peskovdev/tdrop that referenced this issue Oct 1, 2023
@peskovdev
Copy link
Contributor Author

is there any update on this issue

Sorry for the delay.
Yeah, I have checked, and with --sync flag it works pretty well!

Also, I have updated the PR. I think we can close this issue.

noctuid pushed a commit to peskovdev/tdrop that referenced this issue Oct 3, 2023
This will ensure that tdrop waits until the window is mapped before activating
it.  Otherwise tdrop can incorrectly focus another desktop.

Fixes issue noctuid#369
@noctuid
Copy link
Owner

noctuid commented Oct 3, 2023

Thanks all!

@noctuid noctuid closed this as completed Oct 3, 2023
@yaaama
Copy link

yaaama commented Nov 22, 2023

is there any update on this issue

Sorry for the delay. Yeah, I have checked, and with --sync flag it works pretty well!

Also, I have updated the PR. I think we can close this issue.

This worked!
I guess the Arch repositories have not updated the package there.

I just wanted to make the solution clear for those that have not got the updated package:

  1. Go into wherever the tdrop program is stored (you can use whereis tdrop command to find it).
  2. Open up the script, and replace find the function map_and_reset_geometry with this new definition:
map_and_reset_geometry() {
	if [[ -n $width ]] && [[ -n $height ]] && [[ -n $xoff ]] \
		   && [[ -n $yoff ]]; then
		xdotool windowmap --sync "$wid" windowmove "$wid" "$xoff" "$yoff" \
				windowsize "$wid" "$width" "$height" 2> /dev/null
	elif [[ -n $width ]] && [[ -n $height ]]; then
		xdotool windowmap --sync "$wid" windowsize "$wid" "$width" "$height" \
				2> /dev/null
	elif [[ -n $xoff ]] && [[ -n $yoff ]]; then
		xdotool windowmap --sync "$wid" windowmove "$wid" "$xoff" "$yoff" \
				2> /dev/null
	else
		xdotool windowmap --sync "$wid" 2> /dev/null
	fi
	# windowmap does not activate the window for all window managers;
	# windowactivate should be run separately after windowmap --sync or it can
	# activate a window on another desktop on some window managers (e.g. bspwm)
	xdotool windowactivate "$wid" 2> /dev/null
}
  1. Save and close the file.
  2. You can try rerunning the tdrop and seeing whether it has fixed the problem.

@noctuid
Copy link
Owner

noctuid commented Nov 22, 2023

I guess the Arch repositories have not updated the package there.

tdrop is not my package and is not supported or recommended. Use tdrop-git.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants