Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QScreen::GrabWindow mouse blinking

    General and Desktop
    2
    10
    2329
    Loading More Posts
    • 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.
    • UndeadBlow
      UndeadBlow last edited by

      Hi, I have code:

      HWND h = FindWindow(NULL, (LPCWSTR)"Some window name");
      if (h == NULL) {
        qDebug() << "Can't get Handle of Window";
        return;
      }
      ++_screens_processed;
      
      const QImage& image = QGuiApplication::primaryScreen()->grabWindow((WId)(h)).toImage();
      

      And I'm doing it fast, about 1 time in 50 ms. And works very good except mouse cursor - it blinking very hard inside windows that is grabbing.
      Someone faced the such? What can I do?

      mrjj 1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion @UndeadBlow last edited by mrjj

        @UndeadBlow said in QScreen::GrabWindow mouse blinking:

        grabWindow

        Hi Docs just says
        "The mouse cursor is generally not grabbed."

        So it sounds like its turned off/on but can not confirm it.

        Browsing the code
        https://code.woboq.org/qt5/qtbase/src/gui/kernel/qscreen.cpp.html

        Didnt not tell me why cursor should blink.

        The windows actual method
        https://code.woboq.org/qt5/qtbase/src/plugins/platforms/windows/qwindowsscreen.cpp.html#_ZNK14QWindowsScreen10grabWindowEyiiii

        UndeadBlow 2 Replies Last reply Reply Quote 0
        • UndeadBlow
          UndeadBlow @mrjj last edited by UndeadBlow

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • UndeadBlow
            UndeadBlow @mrjj last edited by

            @mrjj http://stackoverflow.com/questions/1541492/how-to-code-for-reducing-flicker-need-your-help-with-code-win32-vc-flicker Well... Seems that WinAPI sucks a little. I think we need to introduce some flag into Qt GrabWindow method, for double buffering.

            mrjj 1 Reply Last reply Reply Quote 0
            • mrjj
              mrjj Lifetime Qt Champion @UndeadBlow last edited by

              @UndeadBlow
              It sounds its more related to WM_ERASEBKGND
              But its unclear for me if its the cursor IN the window you grab or if you paint the grabbed
              some place else ?

              UndeadBlow 1 Reply Last reply Reply Quote 0
              • UndeadBlow
                UndeadBlow @mrjj last edited by

                @mrjj blinking cursor in the window I grab.
                I don't draw it somewhere at all.

                mrjj 1 Reply Last reply Reply Quote 0
                • mrjj
                  mrjj Lifetime Qt Champion @UndeadBlow last edited by

                  @UndeadBlow
                  Oh, but that is what link talk about. if u draw it at cursor.
                  Not grabbing it.
                  Double buffer is for flicker free drawing. Not sure it will do anything while grabbing.

                  UndeadBlow 1 Reply Last reply Reply Quote 0
                  • UndeadBlow
                    UndeadBlow @mrjj last edited by UndeadBlow

                    @mrjj Well, you are right. I was inattentive, sorry.
                    But I found where problem is. I've copied Qt GrabWindow code and removed CAPTUREBLT flag (here). And now it's totally ok. Is that bug or something? Maybe we should initiate some interface changes? I think code-user must have ability to pass some flags in Qt GrabWindow to control that.
                    And, well, I don't know how that flag makes cursor to blink.

                    mrjj 1 Reply Last reply Reply Quote 0
                    • mrjj
                      mrjj Lifetime Qt Champion @UndeadBlow last edited by mrjj

                      np, it often happens fighting an issue and reading all over :)

                      Oh, i would never guess on that.
                      Good found!

                      CAPTUREBLT
                      "Includes any windows that are layered on top of your window in the resulting image. By default, the image only contains your window. Note that this generally cannot be used for printing device contexts."

                      So nope, does scream "BLINK" to me :)

                      UndeadBlow 1 Reply Last reply Reply Quote 0
                      • UndeadBlow
                        UndeadBlow @mrjj last edited by

                        @mrjj And funny thing, I mentioned above that with screen recorder mouse blinks a little too. It was IceCream Screen Recorder. And what is funny - it is on Qt :)

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post