Created
June 27, 2014 18:44
-
-
Save kived/4acc358d14fbddde62d4 to your computer and use it in GitHub Desktop.
x11 reparenting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Xlib import display, error | |
import pygame.display | |
def get_current_window(): | |
wminfo = pygame.display.get_wm_info() | |
return wminfo.get('window', None) | |
def swallow(wid, x, y): | |
handler = error.CatchError() | |
parent = get_current_window() | |
if not parent: | |
logger.warning('no parent window') | |
return False | |
d = display.Display() | |
w = d.create_resource_object('window', wid) | |
if not w: | |
logger.warning('no window found') | |
return False | |
atom = d.get_atom('_XEMBED_INFO') | |
w.change_property(atom, atom, 32, [0, 1]) | |
w.change_attributes(override_redirect=True) | |
d.sync() | |
w.reparent(parent, x, y, onerror=handler) | |
w.map(onerror=handler) | |
d.sync() | |
err = handler.get_error() | |
if err: | |
logger.error('X11 Error %d on resource %d, opcode %d %d' % (err.code, err.resource_id, err.major_opcode, err.minor_opcode)) | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment