mirror of https://github.com/m-labs/artiq.git
applets: attempt at fixing embedding bugs on Windows
This commit is contained in:
parent
fef72506e4
commit
28c4d8c2a7
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import os
|
||||||
|
|
||||||
from quamash import QEventLoop, QtWidgets, QtGui, QtCore
|
from quamash import QEventLoop, QtWidgets, QtGui, QtCore
|
||||||
|
|
||||||
|
@ -130,15 +131,22 @@ class SimpleApplet:
|
||||||
|
|
||||||
def create_main_widget(self):
|
def create_main_widget(self):
|
||||||
self.main_widget = self.main_widget_class(self.args)
|
self.main_widget = self.main_widget_class(self.args)
|
||||||
# Qt window embedding is ridiculously buggy, and empirical testing
|
if self.args.embed is not None:
|
||||||
# has shown that the following procedure must be followed exactly:
|
self.ipc.set_close_cb(self.main_widget.close)
|
||||||
|
if os.name == "nt":
|
||||||
|
self.main_widget.show()
|
||||||
|
win_id = int(self.main_widget.winId())
|
||||||
|
self.loop.run_until_complete(self.ipc.embed(win_id))
|
||||||
|
else:
|
||||||
|
# Qt window embedding is ridiculously buggy, and empirical
|
||||||
|
# testing has shown that the following procedure must be
|
||||||
|
# followed exactly on Linux:
|
||||||
# 1. applet creates widget
|
# 1. applet creates widget
|
||||||
# 2. applet creates native window without showing it, and get its ID
|
# 2. applet creates native window without showing it, and
|
||||||
|
# gets its ID
|
||||||
# 3. applet sends the ID to host, host embeds the widget
|
# 3. applet sends the ID to host, host embeds the widget
|
||||||
# 4. applet shows the widget
|
# 4. applet shows the widget
|
||||||
# 5. parent resizes the widget
|
# 5. parent resizes the widget
|
||||||
if self.args.embed is not None:
|
|
||||||
self.ipc.set_close_cb(self.main_widget.close)
|
|
||||||
win_id = int(self.main_widget.winId())
|
win_id = int(self.main_widget.winId())
|
||||||
self.loop.run_until_complete(self.ipc.embed(win_id))
|
self.loop.run_until_complete(self.ipc.embed(win_id))
|
||||||
self.main_widget.show()
|
self.main_widget.show()
|
||||||
|
|
Loading…
Reference in New Issue