how to get tabs x and y coordinates

730 views
Skip to first unread message

Rajesh Katalkar

unread,
Oct 14, 2014, 6:07:26 AM10/14/14
to chromium-...@chromium.org
Hi,
    I want to how to get tabs x and y coordinate from extension .
Currently in desktop mode I am finding "Chrome_RenderWidgetHostHWND" and get its coordinate by getwindowrect in win32 ...But the same is not working for metro mode.
Is there any way to do same from javascript 
   Also as per doc I see there is only width and height propert for tab

PhistucK

unread,
Oct 14, 2014, 6:13:34 AM10/14/14
to Rajesh Katalkar, Chromium-extensions
Not really. You can only guess using window.screenX and window.screenY.


PhistucK

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/b98867aa-72e9-4de2-a04e-2c11e027dd5a%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.

Rajesh Katalkar

unread,
Oct 14, 2014, 6:16:34 AM10/14/14
to PhistucK, Chromium-extensions
I tried that and also screenleft and screentop ..both give same values and when it gives the browser coordinate not the tabs.I want tabs coordinate.Is there a way to calculate it somehow..

PhistucK

unread,
Oct 14, 2014, 6:21:26 AM10/14/14
to Rajesh Katalkar, Chromium-extensions
You can if you have an event (mousemove, click...). There you have a lot of coordinates and screenX and screenY, so you can subtract the one of the other coordinates (I do not remember the ones that are not affected by scrolling, you should test them) from screenX and screenY and you get the coordinates of the content of the tab, I guess.


PhistucK

Rajesh Katalkar

unread,
Oct 14, 2014, 6:42:10 AM10/14/14
to PhistucK, Chromium-extensions
when I am fullscreen the x and y are zero ...x is correct but how to get 'y' ...how to get space of addressbar etc to deduct to get tabs client area coordinates
..can you please provide me a working code

PhistucK

unread,
Oct 14, 2014, 6:53:06 AM10/14/14
to Rajesh Katalkar, Chromium-extensions
window.addEventListener(
 "mousemove",
 function (e)
 {
  console.log("The tab is located at " + (e.screenX - e.clientX) + ", " + (e.screenY - e.clientY));
 },
 false);


PhistucK

Rajesh Katalkar

unread,
Oct 14, 2014, 7:05:01 AM10/14/14
to PhistucK, Chromium-extensions
OK that how you wanted to say...I want it in advance..can I get it from an element

Rajesh Katalkar

unread,
Oct 14, 2014, 7:11:49 AM10/14/14
to PhistucK, Chromium-extensions
I tried your code of mouse move ...if I move mouse to exact start to tabs document client area then it give 0,0 when browser is fullscreen

Rajesh Katalkar

unread,
Oct 14, 2014, 7:15:14 AM10/14/14
to PhistucK, Chromium-extensions
One more thing I want tab's client co-ordinates w.r.t to the browser window or desktop window...

for FF addon I do below to get tab's cordinates as its a XUL based browser...and works perfect...
function GetCurrentTabBox()
{
 var boxobj = null;
 try
  {
   var doc        = windowutils.getMostRecentBrowserWindow().document;
   var appcontent = doc.getElementById('appcontent');//client area xul element  
   if(appcontent!=null)
   {
       console.log("getCurrentTabBox - appcontent found");         
       boxobj = appcontent.boxObject;
       if(boxobj!=null)
       console.log("getCurrentTabBox - boxobj found");       
   }
  }catch(err)
  {
    boxobj = null;
  }
   return boxobj;
}

PhistucK

unread,
Oct 14, 2014, 7:17:40 AM10/14/14
to Rajesh Katalkar, Chromium-extensions
The code I wrote before will give you just that, I think (or you can compute it, because you have everything there).

I am not sure how to get the coordinates without an event.


PhistucK

Rajesh Katalkar

unread,
Oct 14, 2014, 7:18:13 AM10/14/14
to PhistucK, Chromium-extensions
I am using nativehost app feature hence i can use windows api..thats how i get tab coordinates for desktop mode browser

PhistucK

unread,
Oct 14, 2014, 7:22:03 AM10/14/14
to Rajesh Katalkar, Chromium-extensions
Yes, natively, you can do everything. I meant with JavaScript.

If you can natively generate a mouse event in metro mode (I am guessing not), then you can have the coordinates as soon as you do.
If not, sorry. Using JavaScript, I cannot think of a way.


PhistucK

Rajesh Katalkar

unread,
Oct 14, 2014, 7:29:39 AM10/14/14
to PhistucK, Chromium-extensions
In desktop mode I am finding "Chrome_RenderWidgetHostHWND" and get its coordinate ..works good...
But in metro mode that's not working...In metro mode the top window class is "windows.ui.core.corewindow" and if i enumerate it I get nothing...So for Metro mode browser is there any class I can use to find/enumerate windows through api ...I cannot use spy++ as it does not have UIaccess privilege etc..

PhistucK

unread,
Oct 14, 2014, 7:33:56 AM10/14/14
to Rajesh Katalkar, Chromium-extensions
Native related questions are out of scope for this group.
You can ask this (unrelated to extensions) at chromium-dev.


PhistucK

Rajesh Katalkar

unread,
Oct 14, 2014, 7:35:43 AM10/14/14
to PhistucK, Chromium-extensions
can you please move this discussion to chromuim-dev

PhistucK

unread,
Oct 14, 2014, 8:44:57 AM10/14/14
to Rajesh Katalkar, Chromium-extensions
No (and they would not care about the extension related details anyway). Join that group and re-post your specific question regarding the metro mode.


PhistucK

Rajesh Katalkar

unread,
Oct 14, 2014, 9:02:59 AM10/14/14
to PhistucK, Chromium-extensions
I was hopping to get the tab details from extension api...could you please add new property to tab client area to get x and y coordinate like you have added to get width and height property...

PhistucK

unread,
Oct 14, 2014, 9:08:35 AM10/14/14
to Rajesh Katalkar, Chromium-extensions
I certainly cannot, because I am not a Googler or have commit rights. :)

You can, however, file a feature request at crbug.com, if you cannot find one already.


PhistucK

Wolf War

unread,
Oct 18, 2014, 5:04:38 AM10/18/14
to chromium-...@chromium.org
I have similar situation, but I'm calculating position based on full screen or window mode (desktop mode, not metro).
If the browser is in fullscreen, page begins screenY + 61, and if it is in window mode, screenY +81
Those are dimensions without bookmarks bar.
....and in full screen, coordinates are not 0,0 but  -8,-8

I was wondering, is it possible to implement some sort of NaCL module that will listen for those things (basic window management, position, state, focus....)?
I'm clueless about native coding, so excuse me if it sounds silly

PhistucK

unread,
Oct 18, 2014, 5:35:16 AM10/18/14
to Wolf War, Chromium-extensions
I think the tabs or windows APIs can let you know whether it is a full screen, a window or a popup and such and fire events when stuff changes.


PhistucK

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.

Wolf War

unread,
Oct 18, 2014, 8:42:05 AM10/18/14
to chromium-...@chromium.org, wolf...@gmail.com
only useful thing in those situations is "classic" JavaScript APi window.onresize to fire event related to browser window (and it has to be part of content script, not exactly 100% working solution).
Chrome windows API doesn't fire any method/listener if window change size or position. There is a some work onFocusChanged, but in this stage is not very useful (doesn't fire if third-party window takes focus, only works between Chrome windows...)
Only solution is pinging chrome.windows.get and compare changes...

that's why I was hoping/asking, maybe portable native client could somehow listen for those events, fired from OS...

PhistucK

unread,
Oct 18, 2014, 10:19:32 AM10/18/14
to Wolf War, Chromium-extensions
Right, use the various web events for that.
I am pretty sure that Native Client does not give you more events of this type.


PhistucK

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
Reply all
Reply to author
Forward
0 new messages