forked from M-Labs/artiq
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,19 +131,26 @@ 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
|
|
||||||
# has shown that the following procedure must be followed exactly:
|
|
||||||
# 1. applet creates widget
|
|
||||||
# 2. applet creates native window without showing it, and get its ID
|
|
||||||
# 3. applet sends the ID to host, host embeds the widget
|
|
||||||
# 4. applet shows the widget
|
|
||||||
# 5. parent resizes the widget
|
|
||||||
if self.args.embed is not None:
|
if self.args.embed is not None:
|
||||||
self.ipc.set_close_cb(self.main_widget.close)
|
self.ipc.set_close_cb(self.main_widget.close)
|
||||||
win_id = int(self.main_widget.winId())
|
if os.name == "nt":
|
||||||
self.loop.run_until_complete(self.ipc.embed(win_id))
|
self.main_widget.show()
|
||||||
self.main_widget.show()
|
win_id = int(self.main_widget.winId())
|
||||||
self.ipc.fix_initial_size()
|
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
|
||||||
|
# 2. applet creates native window without showing it, and
|
||||||
|
# gets its ID
|
||||||
|
# 3. applet sends the ID to host, host embeds the widget
|
||||||
|
# 4. applet shows the widget
|
||||||
|
# 5. parent resizes the widget
|
||||||
|
win_id = int(self.main_widget.winId())
|
||||||
|
self.loop.run_until_complete(self.ipc.embed(win_id))
|
||||||
|
self.main_widget.show()
|
||||||
|
self.ipc.fix_initial_size()
|
||||||
else:
|
else:
|
||||||
self.main_widget.show()
|
self.main_widget.show()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue