Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-37435

Windows: SetForegroundWindow() does not activate application

    XMLWordPrintable

    Details

    • Commits:
      7b797982751dad3a448037ae99c4c8967529dddc (qtase/5.11, 10.6.2018, 5.11.1)

      Description

      It's a lot of opened bugs here about background process's window activation under windows. The problem is in SetForegroundWindow function. Correct behavior described in Remarks section but not all section works as described. But here is well-known solution AttachThreadInput.

      SetForegroundWindow used in

      qtbase/src/plugins/platforms/windows/qwindowswindow.cpp
      void QWindowsWindow::requestActivateWindow()
      {
          qCDebug(lcQpaWindows) << __FUNCTION__ << this << window();
          // 'Active' state handling is based in focus since it needs to work for
          // child windows as well.
          if (m_data.hwnd) {
              SetForegroundWindow(m_data.hwnd);
              SetFocus(m_data.hwnd);
          }
      }
      

      which used from QWindow::requestActive() and QWidget::activateWindow()

      I think we should implement this workaround.

      I have tested this solution under Windows 7 x64 and it works!

        Attachments

        1. patch1.patch
          1 kB
        2. qtbug14062.zip
          2 kB

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              kleint Friedemann Kleint
              Reporter:
              setosha Anton Sergunov
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes