Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • thg thg
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 829
    • Issues 829
    • List
    • Boards
    • Service Desk
    • Milestones
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • mercurial
  • TortoiseHg
  • thgthg
  • Issues
  • #5048
Closed
Open
Created Feb 28, 2018 by Bitbucket Importer@bitbucket_importerOwner

running 'thg' from the command line does not focus existing workbench window on different monitor

Created originally on Bitbucket by cbillington (Chris Billington)

In Ubuntu 17.10, running gnome-shell, tested under both X and Wayland.

In the specific case where an existing workbench window is already on top (out of the windows on the monitor it is on), it does not get focus if you run 'thg' when a window on a different monitor has focus.

Steps to reproduce:

Run 'thg' from gnome-terminal in a directory that is a hg repo. run 'thg' again from gnome-terminal in the same directory, but this time with gnome-terminal on a separate monitor.

Result: the terminal stays focused, instead of thg workbench

Expected: thg workbench should gain focus.

In all other cases (workbench is not on top on the monitor it is on, or is minimised, or is on the same monitor as the terminal running the second 'thg' command), the workbench correctly gains focus.

I have tried to narrow this bug down and suspect tortoisehg, since there are other things it could be. Other apps that focus existing windows when you launch them, such as sublime text, do not exhibit this behaviour on my setup, so I think I have ruled out it being the window manager's fault.

The below minimal PyQt application, if you drag the window to a different monitor and move focus back to the first monitor, successfully can grab focus again using the same series of method calls, ending in activateWindow(), as used by tortoisehg (qtapp.py, in _handleNewConnection). Python 2, 3, PyQt4, PyQt5, same behaviour in all cases. So I think I have ruled it out being Qt's fault, but there must be some difference between how this test case and Tortoisehg are using Qt (even though this part is the same method calls) since there is a difference in behaviour.

This is not the worst bug ever, but I have keyboard shortcuts to launch tortoisehg and it's surprising when that doesn't have the effect of focusing the existing window.

#!python

import sys

from PyQt4.QtGui import QApplication, QMainWindow
from PyQt4.QtCore import QTimer, Qt

# from PyQt5.QtWidgets import QApplication, QMainWindow
# from PyQt4.QtCore import QTimer, Qt

app = QApplication(sys.argv)

wb = QMainWindow()
wb.setWindowTitle('Main window')
wb.resize(400, 400)
wb.show()

def timeout():
    wb.setWindowState(wb.windowState() & ~Qt.WindowMinimized
                      | Qt.WindowActive)
    wb.show()
    wb.raise_()
    wb.activateWindow()
    wb.activateWindow()

timer = QTimer()
timer.timeout.connect(timeout)
timer.start(5000)

app.exec_()


To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking