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

Cocoa: invalid mouse position reported during window resize

    XMLWordPrintable

Details

    • macOS

    Description

      If the mouse pointer is moved over a QWindow towards the edge, and then the window is resized by that edge, neither QEvent::Leave nor QEvent::MouseMove are delivered during the resize. This only happens if the mouse motion doesn't overshoot the window edge.

      In effect, the window redraws as-if the mouse pointer was at the spot where it has left the window, causing invalid "hover" appearance.

      Here is an example which demonstrates the issue in QML.

      import QtQuick
      Window {
          id: win
          width: 300
          height: 300
          visible: true
          Row {
              Repeater {
                  model: 4
                  Rectangle {
                      width:  win.width/4
                      height: win.height
                      color: Qt.lighter(Qt.rgba(0.5,index/3,0,1),ma.containsMouse ?2.0:1.0)
                      MouseArea {
                          anchors.fill: parent
                          id: ma
                          hoverEnabled: true
                      }
                  }
              }
          }}
      

       

      The underlying issue can be demonstrated at the QWindow level using the following example. When the window is resized by following the procedure outlined above, neither "Leave" nor "Mouse" debug output is produced.

      #include <QGuiApplication>
      #include <QWindow>
      #include <QMouseEvent>
      #include <QDebug>
      
      class MyWindow:public QWindow {
      public:
      	bool event(QEvent *ev) override {
      		if(ev->type() == QEvent::Enter) {
      			qDebug() << "Enter";
      		}
      		if(ev->type() == QEvent::Leave) {
      			qDebug() << "Leave";
      		}
      		if(ev->type() == QEvent::MouseMove) {
      			auto mev = static_cast<QMouseEvent*>(ev);
      			qDebug() << "Mouse" << mev->position();
      		}
      		return QWindow::event(ev);
      	}
      };
      
      int main(int ac, char ** av)
      {
      	QGuiApplication app(ac, av);
      
      	MyWindow w;
      	w.show();
      	app.exec();
      	return 0;
      }
      
      

      Attachments

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

        Activity

          People

            srutledg Shawn Rutledge
            anszom Andrzej Szombierski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes