Bug 70290

Summary: mouse position in konqueror doesn't take into account scrolling
Product: [Applications] konqueror Reporter: Marek Janda <nyx>
Component: khtml ecmaAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: major CC: bda, montel, pupeno
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Marek Janda 2003-12-13 12:37:14 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc version 3.2.3 20030422 (Gentoo Linux 1.4 3.2.3-r3, propolice) 
OS:          Linux

this bug is related to finding position of mouse cursor on the page via javascript. for some time, it worked this way (I tested it in some Konq 3.x when I made it bud I don't remember which version exactly - for some time, I used mostly MozillaFirebird as my primary browser):

function getMouseXY(e) {
  if (navigator.userAgent.indexOf("Konqueror")!=-1) {  // grab the x-y pos if browser is Konqueror
    tempX = e.clientX
    tempY = e.clientY
  } else if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS / Mozilla etc...
    tempX = e.pageX
    tempY = e.pageY
  }
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}
  return true
}

but now, it doesn't take scrolling into account. it always returns values like if I was on top of the page.
(I tried all three ways and none of them works now)

test case is here:
http://www.nyx.cz/code/kbug.html
scroll down, click on some icon and scroll back up to see the context menu there. correct behavior of course is to show the menu somewhere over the icon (x=-10, y=-10 from the area, where the user clicked).
Comment 1 Stephan Kulow 2004-01-13 09:36:45 UTC
I raise that up as I very often didn't notice a popup that appeared out of view because of this bug
Comment 2 Stephan Kulow 2004-01-13 10:56:50 UTC
*** Bug 67580 has been marked as a duplicate of this bug. ***
Comment 3 Philippe Bourdeu d'Aguerre 2004-01-23 18:14:48 UTC
I see the situation like this:
for KDE 3.1:
- clientX/Y reports position in the window
- pageX/Y is undefined

for KDE 3.2
- clientx/Y reports position in the window
- pageX/Y reports also position in the window

Good behaviour is:
- clientx/Y reports position in the window
- pageX/Y reports position in the page

This breaks the common way to find mouse position:
  if (e.pageX || e.pageY) {
    posx = e.pageX
    posy = e.pageY
    }
  else if (e.clientX || e.clientY) {
    posx = e.clientX + document.body.scrollLeft
    posy = e.clientY + document.body.scrollTop
    }
To test, see page http://www.quirksmode.org/js/events/mouseposition.html

Comment 4 Stephan Kulow 2004-01-28 20:59:54 UTC
*** Bug 71842 has been marked as a duplicate of this bug. ***
Comment 5 Dirk Mueller 2004-02-11 04:14:41 UTC
CVS commit by mueller: 

unfiddle various mouse coordinate mess
CCMAIL: 74718-done@bugs.kde.org
CCMAIL: 70290-done@bugs.kde.org


  M +5 -0      ChangeLog   1.202
  M +11 -13    khtmlview.cpp   1.618
  M +25 -3     dom/dom2_events.cpp   1.12
  M +10 -2     dom/dom2_events.h   1.15
  M +6 -0      ecma/kjs_dom.cpp   1.171
  M +2 -6      ecma/kjs_events.cpp   1.82
  M +17 -6     xml/dom2_eventsimpl.cpp   1.44
  M +8 -2      xml/dom2_eventsimpl.h   1.39
  M +13 -10    xml/dom_nodeimpl.cpp   1.228