Results 1 to 8 of 8

Thread: Raspberry Pi / QT5 - mouse focus on application AND in background operating system

  1. #1
    Join Date
    Jun 2016
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Raspberry Pi / QT5 - mouse focus on application AND in background operating system

    Hello

    I am writing an application to be run on Raspberry Pi 3 with Debian based Raspbian distribution. The application uses QT 5.6 and I am developing and cross compiling on a Windows system.

    The application is a full-screen graphical user interface with touch screen.

    When I run the application, everything works as expected, however mouse (touch screen) events/gestures such as clicking buttons, dragging etc also appear to be functioning behind the application. I find that when I close the application, icons have shifted, dialogs have been opened etc.

    This doesn't appear to happen with non-QT applications so I was wondering if anyone here might know what is going on and how to stop it?

    Kind Regards,
    m

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Raspberry Pi / QT5 - mouse focus on application AND in background operating syste

    Very strange, that sounds like a standard X11 setup.

    Does this also happen when the application's window is not full screen?

    Cheers,
    _

  3. #3
    Join Date
    Jun 2016
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Raspberry Pi / QT5 - mouse focus on application AND in background operating syste

    Yes as far as I know it's a standard X11 setup. It uses a window manager "based off of LXDE" which I take to mean it has undergone a few cosmetic changes to make it fit the Raspberry Pi theme but nothing major (as far as I know).

    Also yes it does happen no matter how I configure the application window - full screen or otherwise.

    I am currently doing this:
    Qt Code:
    1. MainWindow w;
    2. w.setWindowFlags( Qt::Window | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
    3. w.setWindowState( Qt::WindowFullScreen | Qt::WindowActive);
    4. w.show();
    5. w.raise();
    To copy to clipboard, switch view to plain text mode 

    I have tried all manner of combinations but the mouse issue seems to remain.

    A couple things I have noticed that may help diagnose the issue:
    • Mouse cursor when application is not loaded shows a black pointer, and disappears after a couple seconds without motion.
    • Mouse cursor when application is not loaded can be moved by touch screen and by external USB mouse.
    • Mouse cursor when application is loaded is a different shape white pointer, always initializes its location to the top left, and always persists.
    • Mouse cursor when application is loaded cannot be moved by touch screen, but can be moved by external USB mouse.



    This hints to me that QT libs are partially overriding the x11/window manager control of mouse events but also continuing to pass events behind the application.

    Also worth noting that when I compile the same application for Windows 10 using QT 5.6, the application works fine.

    Correction: I use QT 5.5 for cross compiling on Raspberry Pi.

    Regards
    m

  4. #4
    Join Date
    Jun 2016
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Raspberry Pi / QT5 - mouse focus on application AND in background operating syste

    Ok I've done more digging

    This is the guide I used to build QT
    http://visualgdb.com/tutorials/raspberry/qt/embedded/

    There is an option "-opengl es2" that is described "“-opengl es2″ option that configures Qt to use the Raspberry Pi framebuffer directly instead of the X11 system.".

    It looks like eglfs is the default platform when executing my program and is designed to operate without a windowing system.

    Additionally I was not able to build with -qt-xcb and so XCB is not currently an option.

    Does this mean I need to recompile QT without -opengl es2 so that I can still access gui desktop features outside my app?

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Raspberry Pi / QT5 - mouse focus on application AND in background operating syste

    Quote Originally Posted by mstew View Post
    I am currently doing this:
    Qt Code:
    1. MainWindow w;
    2. w.setWindowFlags( Qt::Window | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
    3. w.setWindowState( Qt::WindowFullScreen | Qt::WindowActive);
    4. w.show();
    5. w.raise();
    To copy to clipboard, switch view to plain text mode 
    That looks really complicated, are you sure you need this?
    Wouldn't a simple
    Qt Code:
    1. w.showFullscreen();
    To copy to clipboard, switch view to plain text mode 
    Be sufficient, like on any other X11 based desktop?

    Quote Originally Posted by mstew View Post
    There is an option "-opengl es2" that is described "“-opengl es2″ option that configures Qt to use the Raspberry Pi framebuffer directly instead of the X11 system.".
    No, this configures which kind of OpenGL to use, in this case OpenGL ES2 and not "Desktop OpenGL".

    The platform adapter module is selected through the -qpa switch. You want -qpa xcb

    Quote Originally Posted by mstew View Post
    It looks like eglfs is the default platform when executing my program and is designed to operate without a windowing system.
    Yes, looks that way. For running the Qt application as the only UI on the device.
    Also only for programs that don't need support for windows such as dialogs.

    Quote Originally Posted by mstew View Post
    Additionally I was not able to build with -qt-xcb and so XCB is not currently an option.
    I am pretty sure the Rasphian system has XCB libraries, no need for Qt's copy.

    Quote Originally Posted by mstew View Post
    Does this mean I need to recompile QT without -opengl es2 so that I can still access gui desktop features outside my app?
    No, you need to build with the XCB platform plugin enabled.

    Cheers,
    _

  6. #6
    Join Date
    Jun 2016
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Raspberry Pi / QT5 - mouse focus on application AND in background operating syste

    anda_skoa, thank you so much for your input!

    That looks really complicated, are you sure you need this?
    Wouldn't a simple
    Qt Code:
    Switch view

    Qt Code:
    1. w.showFullscreen();
    To copy to clipboard, switch view to plain text mode 

    To copy to clipboard, switch view to plain text mode
    Be sufficient, like on any other X11 based desktop?
    You are right, "w.showFullscreen();" should suffice. The excessive code I have is just a result of desperation to try solve this mouse issue but I see now it should not be needed.


    No, this configures which kind of OpenGL to use, in this case OpenGL ES2 and not "Desktop OpenGL".
    Ok so “-opengl es2″ option is simply described wrong in the link to the guide I used. I will leave this option as it is unrelated.


    I am pretty sure the Rasphian system has XCB libraries, no need for Qt's copy.
    Yes it seems to. At least I can include <xcb/xcb.h> with no issues but when I run with eglfs I'm not sure how it operates.

    FYI, before when I tried to build with QT with the suggested "-qt-xcb" it failed. I did not check why at the time, but maybe I was missing some dev libraries. I have installed all the recommended libraries from this link:
    http://doc.qt.io/qt-5/linux-requirements.html
    So maybe now the -qt-xcb option should work...but it seems like I can leave it as -no-xcb and link to libs.


    The platform adapter module is selected through the -qpa switch. You want -qpa xcb
    I used the available "qt-everywhere-opensource-src-5.5.0". Is it normal that XCB is not default when building this?

    By using this platform switch when building QT, can I still use QT to build my application to run eglfs, i.e. is there a qmake flag to change it?

    Currently the platform options I have when executing my program currently are "eglfs, linuxfb, minimal, minimalegl, offscreen.".


    Regards

    Mikael

  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Raspberry Pi / QT5 - mouse focus on application AND in background operating syste

    Quote Originally Posted by mstew View Post
    Ok so “-opengl es2″ option is simply described wrong in the link to the guide I used. I will leave this option as it is unrelated.
    It is likely a requirement for building the eglfs QPA so its presence might trigger a different default if the -qpa switch is not explicitly setting a different one.

    Quote Originally Posted by mstew View Post
    Yes it seems to. At least I can include <xcb/xcb.h> with no issues but when I run with eglfs I'm not sure how it operates.
    Not sure what you mean.
    You don't need XCB if you are using eglfs, but you don't want to use eglfs, you want to use XCB.

    Quote Originally Posted by mstew View Post
    I used the available "qt-everywhere-opensource-src-5.5.0". Is it normal that XCB is not default when building this?
    It would be the default on Desktop Linux but the device config for the RPi might have a different default.

    Quote Originally Posted by mstew View Post
    By using this platform switch when building QT, can I still use QT to build my application to run eglfs, i.e. is there a qmake flag to change it?
    It should be possible to build both QPA plugins, but why would you want to build the eglfs one if you don't need it anyway?

    Cheers,
    _

  8. #8
    Join Date
    Jun 2016
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Raspberry Pi / QT5 - mouse focus on application AND in background operating syste

    Quote Originally Posted by anda_skoa View Post
    Not sure what you mean.
    You don't need XCB if you are using eglfs, but you don't want to use eglfs, you want to use XCB._
    To clarify, this was a separate piece of code I used to test the inclusion, not the app that I am working on.

    Quote Originally Posted by anda_skoa View Post
    It would be the default on Desktop Linux but the device config for the RPi might have a different default._
    I'll have to look into the config files. I didn't think the guide I used changed much but like you say the '-opengl es2' may have triggered the default platform change.

    Quote Originally Posted by anda_skoa View Post
    It should be possible to build both QPA plugins, but why would you want to build the eglfs one if you don't need it anyway?
    I don't. I Just thought if I try and fail to get XCB working, at least I can revert to EGLFS, though I can always keep my current qt build in a separate folder..

    Cheers
    m

Similar Threads

  1. Replies: 4
    Last Post: 29th July 2015, 06:41
  2. Replies: 1
    Last Post: 12th September 2014, 21:07
  3. Application Lost Focus / Inactive / In Background
    By javed_alam786 in forum Qt Programming
    Replies: 3
    Last Post: 10th May 2011, 11:12
  4. Application Lost Focus / Inactive / In Background
    By javed_alam786 in forum Newbie
    Replies: 2
    Last Post: 10th May 2011, 11:08
  5. Replies: 8
    Last Post: 21st March 2011, 13:40

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.