Skip to content

Commit

Permalink
ec.refocus sets window topmost (#447)
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Larson <[email protected]>
  • Loading branch information
tomstoll and larsoner authored Nov 1, 2022
1 parent d6e602d commit 177e29b
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 30 deletions.
52 changes: 34 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,46 @@ version: 2
jobs:
build_docs:
docker:
- image: circleci/python:3.8.5-buster
- image: cimg/base:current-22.04
steps:
# Get our data and merge with upstream
- checkout
- run: echo $(git log -1 --pretty=%B) | tee gitlog.txt
- run: echo ${CI_PULL_REQUEST//*pull\//} | tee merge.txt
- run: sudo apt update
- run: sudo apt install libglu1-mesa ffmpeg
- run:
command: |
if [[ $(cat merge.txt) != "" ]]; then
echo "Merging $(cat merge.txt)";
git pull --ff-only origin "refs/pull/$(cat merge.txt)/merge";
fi
- run: echo "export DISPLAY=:99" >> $BASH_ENV
- run: echo "export _EXPYFUN_SILENT=true" >> $BASH_ENV
- run: echo "export PATH=~/.local/bin:$PATH" >> $BASH_ENV
- run: echo "export SOUND_CARD_BACKEND=pyglet >> $BASH_ENV" # rtmixer needs pulse, which is a huge pain to get running on CircleCI
- run: /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1400x900x24 -ac +extension GLX +render -noreset;
- run: pip install --quiet --upgrade --user pip
- run: pip install --quiet --upgrade --user numpy scipy matplotlib sphinx pillow pandas h5py mne pyglet psutil sphinx_bootstrap_theme sphinx_fontawesome numpydoc https://api.github.com/repos/sphinx-gallery/sphinx-gallery/zipball/master
name: Merge
command: |
set -eo pipefail
echo $(git log -1 --pretty=%B) | tee gitlog.txt
echo ${CI_PULL_REQUEST//*pull\//} | tee merge.txt
if [[ $(cat merge.txt) != "" ]]; then
echo "Merging $(cat merge.txt)";
git pull --ff-only origin "refs/pull/$(cat merge.txt)/merge";
fi
- run:
name: Prep env
command: |
set -eo pipefail
echo "set -eo pipefail" >> $BASH_ENV
sudo apt update
sudo apt install libglu1-mesa python3.10-venv python3-venv libxft2 ffmpeg ffmpeg xvfb
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1400x900x24 -ac +extension GLX +render -noreset
python3.10 -m venv ~/python_env
echo "export PATH=~/.local/bin:$PATH" >> $BASH_ENV
echo "export SOUND_CARD_BACKEND=pyglet >> $BASH_ENV" # rtmixer needs pulse, which is a huge pain to get running on CircleCI
echo "export OPENBLAS_NUM_THREADS=4" >> $BASH_ENV
echo "export XDG_RUNTIME_DIR=/tmp/runtime-circleci" >> $BASH_ENV
echo "export PATH=~/.local/bin/:$PATH" >> $BASH_ENV
echo "export DISPLAY=:99" >> $BASH_ENV
echo "export _EXPYFUN_SILENT=true" >> $BASH_ENV
echo "source ~/python_env/bin/activate" >> $BASH_ENV
mkdir -p ~/.local/bin
ln -s ~/python_env/bin/python ~/.local/bin/python
echo "BASH_ENV:"
cat $BASH_ENV
- run: pip install --quiet --upgrade pip setuptools wheel
- run: pip install --quiet --upgrade numpy scipy matplotlib sphinx pillow pandas h5py mne "pyglet<2.0" psutil sphinx_bootstrap_theme sphinx_fontawesome numpydoc https://api.github.com/repos/sphinx-gallery/sphinx-gallery/zipball/master
- run: python -c "import mne; mne.sys_info()"
- run: python -c "import pyglet; print(pyglet.version)"
- run: python setup.py develop --user
- run: python setup.py develop
- run: cd doc && make html

- store_artifacts:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/compat_old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
shell: bash -el {0}
strategy:
matrix:
python: ['3.7']
python: ['3.8']
env:
DISPLAY: ':99.0'
steps:
- uses: actions/checkout@v2
name: Checkout
- run: /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1400x900x24 -ac +extension GLX +render -noreset
name: Start Xvfb
- run: sudo apt update -q && sudo apt install -q libglu1-mesa
- run: sudo apt update -q && sudo apt install -q libglu1-mesa gstreamer1.0-alsa
name: Install system dependencies
- uses: conda-incubator/setup-miniconda@v2
with:
Expand All @@ -37,7 +37,7 @@ jobs:
name: 'Setup conda'
- run: |
set -e
conda remove -n test pandas h5py
conda remove -n test pandas h5py alsa-lib
pip install sounddevice rtmixer "pyglet<1.4"
name: Dependencies
- run: git clone --depth=1 https://github.com/LABSN/sound-ci-helpers.git && sound-ci-helpers/auto.sh
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ stages:
maxParallel: 4
matrix:
Python37:
PYTHON_VERSION: '3.7'
PYTHON_VERSION: '3.8'
Python39:
PYTHON_VERSION: '3.10'
steps:
Expand All @@ -66,7 +66,7 @@ stages:
# Until https://github.com/pyglet/pyglet/pull/516 is reverted or fixed, we need to use an older one
pip install --user --upgrade https://github.com/pyglet/pyglet/zipball/pyglet-1.5-maintenance
else
pip install --user --upgrade "pyglet!=1.5.16"
pip install --user --upgrade "pyglet<2.0"
fi
pip install --user -q coverage setuptools h5py pandas pytest pytest-cov pytest-timeout codecov pyglet-ffmpeg mne tdtpy joblib numpydoc pillow
python -c "import mne; mne.sys_info()"
Expand Down
6 changes: 2 additions & 4 deletions expyfun/_experiment_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2182,13 +2182,11 @@ def refocus(self):
m_hWnd = self._win._hwnd
hCurWnd = _user32.GetForegroundWindow()
if hCurWnd != m_hWnd:
# m_hWnd, HWND_TOPMOST, ..., SWP_NOSIZE | SWP_NOMOVE
_user32.SetWindowPos(m_hWnd, -1, 0, 0, 0, 0, 0x0001 | 0x0002)
dwMyID = _user32.GetWindowThreadProcessId(m_hWnd, 0)
dwCurID = _user32.GetWindowThreadProcessId(hCurWnd, 0)
_user32.AttachThreadInput(dwCurID, dwMyID, True)
# _user32.SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0,
# SWP_NOSIZE | SWP_NOMOVE)
# _user32.SetWindowPos(m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0,
# SWP_NOSIZE | SWP_NOMOVE)
self._win.activate() # _user32.SetForegroundWindow(m_hWnd)
_user32.AttachThreadInput(dwCurID, dwMyID, False)
_user32.SetFocus(m_hWnd)
Expand Down
6 changes: 5 additions & 1 deletion expyfun/_sound_controllers/_pyglet.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ def __init__(self, data, fs=None, loop=False, api=None, name=None,

def stop(self, wait=True, extra_delay=0.):
"""Stop."""
self.pause()
try:
self.pause()
# assert timestamp >= 0, 'Timestamp beyond dequeued source memory'
except AssertionError:
pass
self.seek(0.)

@property
Expand Down
2 changes: 1 addition & 1 deletion expyfun/io/tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
verbose=True, version='dev')


@pytest.mark.timeout(10)
@pytest.mark.timeout(20)
def test_parse_basic(hide_window, tmpdir):
"""Test .tab parsing."""
with ExperimentController(*std_args, **std_kwargs) as ec:
Expand Down
2 changes: 1 addition & 1 deletion expyfun/tests/test_experiment_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def test_degenerate():
**std_kwargs)


@pytest.mark.timeout(60)
@pytest.mark.timeout(120)
def test_ec(ac, hide_window, monkeypatch):
"""Test EC methods."""
if ac == 'tdt':
Expand Down

0 comments on commit 177e29b

Please sign in to comment.