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

Mouse cannot focus on vscode when breakpoint on Ubuntu when mouse pressed #4244

Open
Tsunami014 opened this issue May 22, 2024 · 1 comment

Comments

@Tsunami014
Copy link

I seem to have encountered an issue: When I am holding down the mouse in my pygame project, vscode hits a breakpoint then none of my clicks on the vscode window do anything.

Here is some code which you can run to replicate it which causes this error for me:

import pygame
pygame.init()

win = pygame.display.set_mode((500, 500))

r = True
while r:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            r = False
    if pygame.key.get_pressed()[pygame.K_SPACE]:
        pass # Breakpoint here works if mouse isn't down
    win.fill((255, 255, 255))
    pygame.display.update()

Steps to replicate:

  1. Make a breakpoint after the key.get_pressed if statement on the pass (where the comment is)
  2. Run the code
  3. Hold the mouse down on the pygame window and while holding it down press space.

Other things to note

  1. The keyboard input still works when this error occurs, it's just the mouse clicks are not able to be detected at all.
  2. This error occurs at any time it breakpoints when you have your mouse held down.
  3. If you run this code again and without holding the mouse down press space, you can see it doesn't have the error!
  4. I think this is not an issue on Windows as I didn't have this issue when I ran it there last.
  5. At one point I disabled all my extensions but the python debugger and yet it still failed.

Video showcase of what happens can be seen here. This is the exact steps above, recorded as a video. To stop running, you can either force quit the window or what I did was press f5 (my shortcut for stop) and it stopped (the keyboard still works when in this state) and the mouse started working again, and I re-ran it but the second time was without holding down the mouse and you could see it working properly.
I've tried modifying the debug focus settings in vscode to no avail.

I'm running Ubuntu 22.04.4 LTS with pygame 2.5.2 (SDL 2.28.2, Python 3.10.12) and vscode version 1.89.1, with the windowing system being Wayland.

Any help would be appreciated!

@Tsunami014
Copy link
Author

Tsunami014 commented May 30, 2024

I FIGURED OUT SOMETHING

If you release your mouse fast enough and then run pygame.event.___ (in this case I used .pump()) then it will not freeze!

import pygame
pygame.init()

win = pygame.display.set_mode((500, 500))

r = True
while r:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            r = False
    if pygame.key.get_pressed()[pygame.K_SPACE]:
        import time
        time.sleep(1)
        pygame.event.pump()
        pass # Breakpoint here works if you release your mouse in the 1 second window provided by the time.sleep!!
    win.fill((255, 255, 255))
    pygame.display.update()

To see it:

  1. Run the code
  2. Hold down the mouse and while holding down the mouse press space
  3. BUT release your mouse in the 1 second before it breakpoints
  4. You can see it works properly again!

I'll just put those 3 lines before every piece of code that fails for now until it gets fixed

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

1 participant