Gnome 및 FVWM2에서 GTK::Socket 및 Gtk::Plug의 예기치 않은 동작

Gnome 및 FVWM2에서 GTK::Socket 및 Gtk::Plug의 예기치 않은 동작

FVWM2에서 다음 코드를 실행하면 정상적으로 작동합니다. 그러나 데스크탑을 Gnome으로 변경하면 내장된 창이 내장되는 대신 삭제됩니다.

왜 그런 겁니까? 내가 놓친 게 무엇입니까? ...

코드는 아래에 있지만 기본적으로 수행하는 작업은 포크뿐입니다. 하위 프로세스에서는 VPython 창을 생성하고 영원히 유휴 상태로 둡니다. 상위 창에서 GTK 창을 생성하고, 하위 창의 창 ID가 무엇인지 알아낸 다음, 이를 GTK::Socket에 삽입해 봅니다.

VPython 부분은 여기서 관련이 없을 수도 있습니다.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
import sys
import os
import re
import time
from visual import *


def find_window_id (title):
    """Gets the OpenGL window ID."""
    pattern = re.compile('0x[0-9abcdef]{7}')
    proc = subprocess.Popen(['xwininfo', '-name', title],
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    errors = proc.stderr.readlines()
    if errors:
        return None
    for line in proc.stdout.readlines():
        match = pattern.findall(line)
        if len(match):
            return long(match[0], 16)
    return None



class Setting ():
    """VPython/OpenGL class."""

    def __init__ (self, w=256, h=256, title='OpenGL via VPython'):
        """Initiator."""
        self.width = w
        self.height = h
        self.title = title
        self.scene = display.get_selected() 
        self.scene.title = self.title
        self.scene.width = self.width
        self.scene.height = self.height
        self.sphere = sphere()



class GTKDisplay ():

    def __init__ (self, winID):
        """Initiator: Draws the GTK GUI."""
        import gtk
        import pygtk
        self.OpenGLWindowID = winID
        window = gtk.Window()
        window.show()
        socket = gtk.Socket()
        socket.show()
        window.add(socket)
        window.connect("destroy", lambda w: gtk.main_quit())
        socket.add_id(long(self.OpenGLWindowID))
        gtk.main()



def main ():
    """Main entry point."""
    name = 'sphere OpenGL window'
    child_pid = os.fork()
    if 0 == child_pid:
        sut = Setting(title=name)
    else:
        winID = None
        while not winID:
            time.sleep(.1)
            winID = find_window_id(name)
        try:
            gui = GTKDisplay(winID)
        except KeyboardInterrupt, err:
            print '\nAdieu monde cruel!'


if __name__ == "__main__":
    main()

추신: 예, 후속 조치입니다.이 문제그리고이것.

관련 정보