I have a xul:panel on my firefox extension. I give the position to display acording to screen.width and screen.height. My problem appears when I have multiple monitors and I start the browser on the first monitor, it appears on the second one and the xul:panel is drawn according to the first screen’s resolution on the second one. Is there a solution to draw according to the second screen’s resolution?
Share
Background:
When I was developing a mutli-monitor application based on XULRunner for work, I found that you just couldn’t predict where the window manager would place windows launched after the initial launch of your main application/browser window.
XULRunner did correctly give me:
It did not correctly respect multi-monitor geometry when I specified a set of window coordinates that would have placed the window on a specific monitor (rather the window manager placed the new window wherever it pleased).
That left me with the task of somehow doing the following:
(because moving the window would sometimes lose window focus)
I was able to achieve both with the help of an external DLL loaded/used by js-ctypes.
Example for Win32:
Here’s are the basics for binding the external DLL to JavaScript. This example only covers Win32, but I also did this for Linux and for MacOSX (which were easier & harder respectively compared to Win32).
There are 3 parts:
I build a simple GUI DLL project with the later two files & compiled
wmctrl.dll, depending onmsvcr100.dll, and used Dependency Walker to find the “plain C” symbols exported by the DLL for use by js-ctypes.I also built a JavaScript library around the APIs which allowed to manipulate, track & persist window state/geometry for multiple windows over multiple runs of the application, but that’s not really relevant to this simple example.
In privileged JavaScript code:
wmctrldll.h
wmctrldll.cpp