Skip to content

Commit

Permalink
applets: attempt at fixing embedding bugs on Windows
Browse files Browse the repository at this point in the history
sbourdeauducq committed Feb 19, 2016
1 parent fef7250 commit 28c4d8c
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions artiq/applets/simple.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import argparse
import asyncio
import os

from quamash import QEventLoop, QtWidgets, QtGui, QtCore

@@ -130,19 +131,26 @@ def ipc_close(self):

def create_main_widget(self):
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:
self.ipc.set_close_cb(self.main_widget.close)
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()
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
# 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:
self.main_widget.show()

0 comments on commit 28c4d8c

Please sign in to comment.