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

Alt press-release makes focus stuck in menu if XDG_CURRENT_DESKTOP ≠ kde

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Need More Info
    • Priority: Not Evaluated
    • Resolution: Incomplete
    • Affects Version/s: 5.13.0
    • Fix Version/s: None
    • Component/s: Widgets: Main Window
    • Labels:
      None
    • Platform/s:
      All

      Description

      When XDG_CURRENT_DESKTOP=kde, the QMenu works fine. However if XDG_CURRENT_DESKTOP=gnome, then pressing and immediately releasing Alt results in focus getting stuck in menu.

      But here's the twist: actually, the problem is present for any value of this variable, even XDG_CURRENT_DESKTOP=foo. So this problem affects all existing platforms where the value is not set to kde, this is pretty bad.

      Steps to reproduce:

      1. Compile and build testcase (in terms of terminal commands):

      $ cat mainwindow.h
      #ifndef MAINWINDOW_H
      #define MAINWINDOW_H
      
      #include <QMainWindow>
      
      QT_BEGIN_NAMESPACE
      class QAction;
      class QMenu;
      QT_END_NAMESPACE
      
      class MainWindow : public QMainWindow {
          Q_OBJECT
      
      public:
          MainWindow();
      
      private:
          QMenu *fileMenu;
          QAction *exitAct;
      };
      
      #endif
      $ cat main.cpp
      #include <QApplication>
      #include <QtWidgets>
      #include "mainwindow.h"
      
      MainWindow::MainWindow() {
          exitAct = new QAction(tr("&Exit"), this);
          exitAct->setShortcuts(QKeySequence::Quit);
          exitAct->setStatusTip(tr("Exit the application"));
          connect(exitAct, &QAction::triggered, this, &QWidget::close);
      
          fileMenu = menuBar()->addMenu(tr("&File"));
          fileMenu->addSeparator();
          fileMenu->addAction(exitAct);
      
          setMinimumSize(160, 160);
      }
      
      int main(int argc, char *argv[]) {
          QApplication app(argc, argv);
          MainWindow window;
          window.show();
          return app.exec();
      }
      $ cat menus.pro
      QT += widgets
      
      HEADERS = mainwindow.h
      SOURCES = main.cpp
      CONFIG+=debug
      $ qmake menus.pro
      $ make
      g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /usr/include/qt -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib/qt/mkspecs/linux-g++ -o main.o main.cpp
      g++ -pipe -g -Wall -W -dM -E -o moc_predefs.h /usr/lib/qt/mkspecs/features/data/dummy.cpp
      /usr/bin/moc -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include /home/constantine/Projects/qt-menu-example/moc_predefs.h -I/usr/lib/qt/mkspecs/linux-g++ -I/home/constantine/Projects/qt-menu-example -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I/usr/include/c++/9.1.0 -I/usr/include/c++/9.1.0/x86_64-pc-linux-gnu -I/usr/include/c++/9.1.0/backward -I/usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include -I/usr/local/include -I/usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include-fixed -I/usr/include mainwindow.h -o moc_mainwindow.cpp
      g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /usr/include/qt -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtCore -I. -isystem /usr/include/libdrm -I/usr/lib/qt/mkspecs/linux-g++ -o moc_mainwindow.o moc_mainwindow.cpp
      g++  -o menus main.o moc_mainwindow.o   /usr/lib/libQt5Widgets.so /usr/lib/libQt5Gui.so /usr/lib/libQt5Core.so /usr/lib/libGL.so -lpthread
      $ XDG_CURRENT_DESKTOP=foo ./menus
      

      2. After application appeared, press Alt key, and immediately release.
      3. Press Enter

      Expected

      Nothing

      Actual

      "File" menu gets opened.

      Additional infomation

      I remember using the workaround with "kde" for a very long time, so at least with qt5 the problem has been possibly always.

      Qt4 doesn't have the problem though.

        Attachments

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

          Activity

            People

            • Assignee:
              qt.team.quick.subscriptions Qt Quick and Widgets Team
              Reporter:
              constantine2 constantine
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes