Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does X choke after I draw to the root window
    text
    copied!<p>For background, I'm running Debian Lenny, and have tried this with both GNOME and Fluxbox.</p> <p>Anyway, I've been looking at how to draw on the desktop, and I found and tried this code here: <a href="http://blog.prashanthellina.com/2007/08/24/drawing-on-your-desktop/" rel="nofollow noreferrer">http://blog.prashanthellina.com/2007/08/24/drawing-on-your-desktop/</a></p> <p>It worked fine, except upon terminating it (by hitting control C), X loses it's ability to create new windows.</p> <p>I had thought that maybe the problem was pygame not releasing some resource, so I added in a block of code to trap the kill signal, giving me the following:</p> <pre><code>""" Run the following command in the shell before executing this script export SDL_WINDOWID=`xwininfo -root|grep "id:"|sed 's/^.*id: //'|sed 's/ (.*$//'` """ import pygame import sys import random import time import signal pygame.init() window = pygame.display.set_mode((1280, 1024)) screen = pygame.display.get_surface() def handle_sigint(signum, frame): """I want to ensure resources are released before bailing.""" print("SIGINT received."); pygame.display.quit() pygame.quit() sys.exit(0) # Set handler to catch C^C Interupts signal.signal(signal.SIGINT, handle_sigint) while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit(0) x = random.choice(range(640)) y = random.choice(range(480)) radius = random.choice(range(100)) col_r = random.choice(range(255)) col_g = random.choice(range(255)) col_b = random.choice(range(255)) time.sleep(.03) rect = pygame.draw.circle(screen, (col_r, col_g, col_b), (x,y), radius) pygame.display.update(rect) </code></pre> <p>And so I tried again. The print statement in the interrupt handler tells me that the handler does run when I quit, but I still have the same problem. And even more interestingly, X has no problems while it's running. It's only after terminating it.</p> <p>Might anybody out there have any idea what's happening, and what I can do to fix the code so it doesn't wreck my X session? Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload