Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. How to find the absolute screen position of an element on a webpage.
Forum Updated to NodeBB v4.3 + New Features

How to find the absolute screen position of an element on a webpage.

Scheduled Pinned Locked Moved Unsolved Qt WebKit
6 Posts 2 Posters 3.9k Views 1 Watching
  • 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.
  • G Offline
    G Offline
    grheard
    wrote on last edited by
    #1

    Hello.

    I'm working on support for a video overlay on an embedded target. As this is an overlay, the video driver works with absolute screen positions. Webkit's underlying media player's paint method is called with coordinates that are relative to the web page. How can I take those relative coordinates and find the absolute screen coordinates?

    Any help or direction is greatly appreciated.

    K 1 Reply Last reply
    0
    • G grheard

      Hello.

      I'm working on support for a video overlay on an embedded target. As this is an overlay, the video driver works with absolute screen positions. Webkit's underlying media player's paint method is called with coordinates that are relative to the web page. How can I take those relative coordinates and find the absolute screen coordinates?

      Any help or direction is greatly appreciated.

      K Offline
      K Offline
      Konstantin Tokarev
      wrote on last edited by
      #2

      @grheard QWebPageClient::mapToOwnerWindow() converts point from page coordinate system to coordinate system of QWindow where page belongs, then you can use QWindow::mapToGlobal to get it in absolute screen coordinates.

      To use this approach you will have to add interface in WebCore (e.g. I named it PlatformPlayerClient), call it from your MediaPlayerPrivate implementation, and implement it in WebKit layer.

      In Qt4 times I used simpler approach of accessing QWebView inside MediaPlayerPrivate via Document pointer (Document -> Frame -> FrameView -> HostWindow -> QWebPageClient -> ownerWidget), but I got rid if that because

      • this is ugly layering violation
      • it is not really compatible with separation of QtWebKitWidgets and QtWebKit libraries in Qt5
      • it is principally incompatible with WebKit2
      1 Reply Last reply
      1
      • G Offline
        G Offline
        grheard
        wrote on last edited by
        #3

        Thanks for the reply.

        In Qt 5.5.1 qtwebkit, MediaPlayer->FrameView->HostWindow->screenToRootView(IntPoint) appears to return the absolute IntPoint on the screen. I'll need to perform a few more tests to be certain. It doesn't seem to violate the layering you mention because the call stays within WebCore and does not reach the webkit widget layer.

        G K 2 Replies Last reply
        0
        • G grheard

          Thanks for the reply.

          In Qt 5.5.1 qtwebkit, MediaPlayer->FrameView->HostWindow->screenToRootView(IntPoint) appears to return the absolute IntPoint on the screen. I'll need to perform a few more tests to be certain. It doesn't seem to violate the layering you mention because the call stays within WebCore and does not reach the webkit widget layer.

          G Offline
          G Offline
          grheard
          wrote on last edited by
          #4

          @grheard said in How to find the absolute screen position of an element on a webpage.:

          In Qt 5.5.1 qtwebkit, MediaPlayer->FrameView->HostWindow->screenToRootView(IntPoint) appears to return the absolute IntPoint on the screen.

          Nevermind. This gives the absolute position on the page, but not the screen.

          K 1 Reply Last reply
          0
          • G grheard

            @grheard said in How to find the absolute screen position of an element on a webpage.:

            In Qt 5.5.1 qtwebkit, MediaPlayer->FrameView->HostWindow->screenToRootView(IntPoint) appears to return the absolute IntPoint on the screen.

            Nevermind. This gives the absolute position on the page, but not the screen.

            K Offline
            K Offline
            Konstantin Tokarev
            wrote on last edited by
            #5

            @grheard BTW, you may want to use QtWebKit TP5 with Qt 5.5.1. It may require you to adjust your player code, but it is much better compatible with modern web sites

            https://github.com/annulen/webkit/releases/tag/qtwebkit-tp5

            1 Reply Last reply
            0
            • G grheard

              Thanks for the reply.

              In Qt 5.5.1 qtwebkit, MediaPlayer->FrameView->HostWindow->screenToRootView(IntPoint) appears to return the absolute IntPoint on the screen. I'll need to perform a few more tests to be certain. It doesn't seem to violate the layering you mention because the call stays within WebCore and does not reach the webkit widget layer.

              K Offline
              K Offline
              Konstantin Tokarev
              wrote on last edited by
              #6

              @grheard BTW, simply accessing Document from MediaPlayer is considered a layering violation in modern WebKit (i.e. WebCore/platform and rest of WebCore are different layers). You should work with MediaPlayerClient only.

              1 Reply Last reply
              0

              • Login

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