Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Catching Qt X11 3dMouse events in child thread
Forum Update on Monday, May 27th 2025

Catching Qt X11 3dMouse events in child thread

Scheduled Pinned Locked Moved Unsolved General and Desktop
3dmousethreadingeventx11
2 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MichalFasanek
    wrote on 20 Apr 2016, 22:35 last edited by
    #1

    I want to use 3dConnexion mouse in a 3D software.

    I am working on X11 Linux implementation, where mouse should be just a module checking for signals in its own child thread for events coming to main application window. Then it should signal a slot to manipulate application.

    However, I ran into problems with threading. I am trying to catch events through re-implementation of x11Event virtual class. When I run loop to catch events in child thread, I receive system error SIGSEGV. I figured out this is most likely answer to my problem:
    passing x11 events in qt

    Yet I have no idea how to fix this. I tried not using child thread but the loop for checking events really renders application window unusable. Thanks for any hints.

    Maybe it will be helpful to show the loop itself.

            Display *display;
            Window xwindow = window->winId();
            std::vector<float> signal_data;
            XEvent report;
            MagellanFloatEvent MagellanEvent;
    
    		bool MagellanLoop = true;
    		display = QX11Info::display();
    
    		/************************* Create 3D Event Types ***************************/
    		if ( !MagellanInit( display, xwindow ) ) {
    			qDebug() << "No driver is running. Exit ... " << endl;
    			exit(EXIT_FAILURE);
    		}
    		else {
    			qDebug() << "Mouse3dDevice::Mouse3DLinux: MagellanInit() = Success!" << endl;
    		}
    		/************************* Main Loop ***************************************/
    
    		while( MagellanLoop ) {
    			if( ! window->x11Event( &report ) ) {
    				qDebug() << "EventType = " << report.type << endl;
    				if ( report.type == ClientMessage ) {
    					if ( MagellanTranslateEvent( display, &report, &MagellanEvent, 1.0, 1.0 ) == MagellanInputMotionEvent) {
    						MagellanRemoveMotionEvents( display );
    
    						signal_data.clear();
    						signal_data.push_back(MagellanEvent.MagellanData[ MagellanX ]);
    						signal_data.push_back(MagellanEvent.MagellanData[ MagellanY ]);
    						signal_data.push_back(MagellanEvent.MagellanData[ MagellanZ ]);
    						signal_data.push_back(MagellanEvent.MagellanData[ MagellanA ]);
    						signal_data.push_back(MagellanEvent.MagellanData[ MagellanB ]);
    						signal_data.push_back(MagellanEvent.MagellanData[ MagellanC ]);
    
    						qDebug() <<  "x=" << signal_data[0] <<
    									"y=" << signal_data[1] <<
    									"z=" << signal_data[2] <<
    									"a=" << signal_data[3] <<
    									"b=" << signal_data[4] <<
    									"c=" << signal_data[5] << endl;
    
    						emit Mouse3dDevice::Move3d(signal_data);
    					}
    					else {
    						qDebug() << "Unrecognized - Not MagellanInputMotionEvent" << endl;
    					}
    				}
    			}
    		}
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 21 Apr 2016, 21:26 last edited by
      #2

      Hi and welcome to devnet,

      What backtrace do you get from the crash ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      2/2

      21 Apr 2016, 21:26

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved