Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding out how blur() works...

8 views
Skip to first unread message

kevin...@bellsouth.net

unread,
Nov 30, 2006, 5:58:29 PM11/30/06
to
I am trying to find what makes the browser do what it does when
window.blur() gets called. I have the code building -- but where to go
from here. dom/src/base/nsGlobalWindow.cpp seems likely enough, but I
thought I would paste a note for some assistance before I dig in.

Is there any documentation that might describe some of the hierarchy or
methodology?

Thanks in advance,

-Kevin

kevin...@bellsouth.net

unread,
Nov 30, 2006, 6:12:15 PM11/30/06
to
By-the-way, my ultimate goal is to figure out how to make the browser
minimize on a window.blur() event. Any way to configure/enable or
re-code this behaviour.

-Kevin

smaug

unread,
Nov 30, 2006, 6:37:08 PM11/30/06
to
kevin...@bellsouth.net wrote:
> By-the-way, my ultimate goal is to figure out how to make the browser
> minimize on a window.blur() event. Any way to configure/enable or
> re-code this behaviour.

If you really want to do that, I think adding capturing event listener
for 'blur' to topmost chrome window and then calling minimize()
http://mxr-test.landfill.bugzilla.org/mxr-test/seamonkey/source/dom/public/idl/base/nsIDOMChromeWindow.idl#67
should work.

kevin...@bellsouth.net

unread,
Dec 1, 2006, 9:18:02 AM12/1/06
to
Thanks, smaug.

I guess I need to start reading chrome documentation now -- I am not
familiar with that at all so this might pose a bit of a problem. I am
currently reading the mozilla docs on this, but if you have any
pointers that might save me some time, it would be greatly appreciated.

Thanks for the help!

-Kevin

kevin...@bellsouth.net

unread,
Dec 1, 2006, 9:34:25 AM12/1/06
to
Of the files to add this handler, can an idl contain a handler? And is
the _xpidlgen stuff is the output of the idl after it is
built/compiled? In looking at nsGlobalWindow.cpp, does this own all of
the chrome windows? I assume chrome windows are subsets of the main
application, where they get put into window frames/tabs, etc?

-Kevin

DigDug

unread,
Dec 12, 2006, 12:37:46 PM12/12/06
to
I think you misunderstand. I'm no expert, but I think he's just
suggesting writing something like:

function min() {
window.minimize();
}

window.addEventListener('blur', min, false);

Daniel Brooks

unread,
Dec 13, 2006, 12:55:10 AM12/13/06
to
"DigDug" <hold...@gmail.com> writes:

Yarrg, just do |addEventListener('blur', minimize, false);|. The
window object is the actually the default scope, so you almost never
actually need to say window.foo to get foo. Anyway, that's just my 2
cents, I don't actually know what the real question was.

db48x

gocaveman

unread,
Dec 19, 2006, 6:16:16 AM12/19/06
to
I understand that there is no such thing as window.minimize(), in
Javascript at any rate. It would be lovely if there was. Were such a
thing possible, I could just replace the following blur() with
minimize.

<html><head></head>
<body onLoad="window.blur()">
</body>
</html>

Or are you suggesting something different?

Thanks DigDug,

-Kevin

Martijn

unread,
Dec 19, 2006, 6:28:36 AM12/19/06
to gocaveman, dev-apps...@lists.mozilla.org
On 19 Dec 2006 03:16:16 -0800, gocaveman <kevin...@bellsouth.net> wrote:
> I understand that there is no such thing as window.minimize(), in
> Javascript at any rate. It would be lovely if there was. Were such a
> thing possible, I could just replace the following blur() with
> minimize.

I suggest you post a message to the whatwg asking this. I know they
have been busy defining all kinds of properties and methods on the
Window object. I think this would be a handy addition to that.
See: http://dev.w3.org/cvsweb/~checkout~/2006/webapi/Window/publish/Window.html
for what appears to be the current document on the Window object.

Regards,
Martijn


--
Martijn Wargers
Help Mozilla!
http://weblogs.mozillazine.org/qa/
http://www.mozilla.org/contribute/

gocaveman

unread,
Dec 19, 2006, 6:33:25 AM12/19/06
to
Thanks, Daniel -- good to know. The original question is how to force
the browser to minimize like IE or Netscape through javascript (like
using <body onLoad="window.blur()"> as I posted above). Unfortunately
it seems this is a bug that will not be an easy one to fix. Last I
checked, there are >> 100 bugs with the word 'blur' in bugzilla, most
of which are neither fixed nor assigned.

I just need some answers to understand the system better. I have
posted similar questions multiple times, and tried hanging out in
Chatzilla fishing for answers, but usually I just get a workaround that
in the end, doesn't work (I am sad to say).

It just seems so easy a problem to find a work-around for, I think is
the problem, when in reality, is going to be a difficult problem to
find a real solution for. I would love of course for someone to prove
me wrong here... (any volunteers?) :-)

-Kevin

gocaveman

unread,
Dec 19, 2006, 6:49:45 AM12/19/06
to
Thanks Martijn, although I am not sure what the whatwg might be, or
where I would go to find it. The specification was interesting enough,
and I managed to track down blur(), although the behaviour wasn't
altogether clear to me what is supposed to happen when window.blur() is
called. Take the focus away from the object, so when the window loses
focus, it seems like minimizing would be correct, as in the case for IE
and Netscape. Since Firefox does nothing on the existance for a single
window, and does the funky chicken window dance when multiple windows
exist, it would seem to me that the specification has perhaps been
mis-interpreted, or mis-implemented.

What is the bubbling phase, at any rate?

http://www.w3.org/TR/DOM-Level-3-Events/events.html
http://www.w3.org/TR/DOM-Level-3-Events/events.html#event-blur

Thanks for that, at any rate -- it was interesting.

-Kevin

Martijn

unread,
Dec 19, 2006, 7:27:24 AM12/19/06
to gocaveman, dev-apps...@lists.mozilla.org
On 19 Dec 2006 03:49:45 -0800, gocaveman <kevin...@bellsouth.net> wrote:
> Thanks Martijn, although I am not sure what the whatwg might be, or
> where I would go to find it. The specification was interesting enough,

See http://whatwg.org/


> and I managed to track down blur(), although the behaviour wasn't
> altogether clear to me what is supposed to happen when window.blur() is
> called. Take the focus away from the object, so when the window loses
> focus, it seems like minimizing would be correct, as in the case for IE
> and Netscape. Since Firefox does nothing on the existance for a single
> window, and does the funky chicken window dance when multiple windows
> exist, it would seem to me that the specification has perhaps been
> mis-interpreted, or mis-implemented.

That's not what I find in IE7, with a quick test.
In IE7, I see that the browser looses the focus, but it doesn't
minimise to the task bar.

> What is the bubbling phase, at any rate?

A quick Google search gave me this:
http://www.xulplanet.com/tutorials/xultu/events.html
"
The event is then sent to the XUL in phases. The first phase is the
capturing phase, in which the event is first sent to the window, then
to the document, followed by each ancestor of the XUL element where
the event occured downwards until it reaches that element. Then, the
event is sent to that XUL element. Finally, during the bubbling phase,
the event is sent to each element back upwards until it reaches the
window again. You can respond to an event during either the capturing
or bubbling phase. Once the event has finished propagating, any
default action will occur, which is the built in behaviour of the
element.
"

Regards,
Martijn

That's when the event bubbles upward


> http://www.w3.org/TR/DOM-Level-3-Events/events.html
> http://www.w3.org/TR/DOM-Level-3-Events/events.html#event-blur
>
> Thanks for that, at any rate -- it was interesting.
>
> -Kevin
>
> Martijn wrote:
> > On 19 Dec 2006 03:16:16 -0800, gocaveman <kevin...@bellsouth.net> wrote:
> > > I understand that there is no such thing as window.minimize(), in
> > > Javascript at any rate. It would be lovely if there was. Were such a
> > > thing possible, I could just replace the following blur() with
> > > minimize.
> >
> > I suggest you post a message to the whatwg asking this. I know they
> > have been busy defining all kinds of properties and methods on the
> > Window object. I think this would be a handy addition to that.
> > See: http://dev.w3.org/cvsweb/~checkout~/2006/webapi/Window/publish/Window.html
> > for what appears to be the current document on the Window object.
> >
> > Regards,
> > Martijn
> >
> >
> > --
> > Martijn Wargers
> > Help Mozilla!
> > http://weblogs.mozillazine.org/qa/
> > http://www.mozilla.org/contribute/
>

> _______________________________________________
> dev-apps-firefox mailing list
> dev-apps...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-apps-firefox

gocaveman

unread,
Dec 19, 2006, 8:29:43 AM12/19/06
to
So, are you suggesting that my best strategy for a solution is to dump
Firefox for any version of IE except v7.0, or any version of Netscape?
I need to either minimize the broswer through a script, or hide the
browser altogether so I can execute cgi scripts through it (headless
mode). Whatever direction I need to go to get there -- just let me
know.

Browsing specs is interesting and helpful, but it doesn't do much to
solve my problem. No offense, but I am just frustrated trying to get
answers. Good to know IE7 is broken as well. Saves me the effort of
testing it.

Thanks again for the input,

Martijn

unread,
Dec 19, 2006, 8:35:15 AM12/19/06
to gocaveman, dev-apps...@lists.mozilla.org
Oh sorry, I don't think there is a way to reliably minimise or hide
the browser by script, not in Firefox, nor in Opera or IE7, so I don't
think your problem is solvable.
Note that browsers like Firefox (and probably also Opera and Safari)
don't allow scripts to focus or blur windows by script.

Regards,
Martijn

gocaveman

unread,
Dec 20, 2006, 6:35:43 AM12/20/06
to
That is a shame. We need the functionality to run 'headless', like was
possible in IE and Netscape, to make the browser window act like a
completely different application which we feed HTML pages through using
perl scripts. It is for a battle system which is mostly X-Windows (all
but a few Netscape windows where the instructions are piped in). All
of the combined windows cover the entire screen.

I guess I am on my own to solve the problem. I know c++ well, but the
whole architecture and interaction of chrome and IDLs are a bit tough
to figure out who calls what, and when is what I was hoping to find
answers to. That, and where do I find help. The only IRC I have found
anyone on is #Firefox and #ExtDev.

-Kevin

Martijn

unread,
Dec 20, 2006, 7:23:19 AM12/20/06
to gocaveman, dev-apps...@lists.mozilla.org
On 20 Dec 2006 03:35:43 -0800, gocaveman <kevin...@bellsouth.net> wrote:
> That is a shame. We need the functionality to run 'headless', like was
> possible in IE and Netscape, to make the browser window act like a
> completely different application which we feed HTML pages through using
> perl scripts. It is for a battle system which is mostly X-Windows (all
> but a few Netscape windows where the instructions are piped in). All
> of the combined windows cover the entire screen.

Oh, this isn't a web application?
I mean, you have chrome privileges?
Well, in that case, I think this is what you want then:
http://wargers.org/mozilla/enhanced_privileges/minimize_window.htm
It works when you save the file to your computer and then let it run
(you need to allow the page to run with enhanced privileges).

Regards,
Martijn

gocaveman

unread,
Dec 20, 2006, 7:39:20 AM12/20/06
to
You rock, dude! Thanks for the help. It worked like a champ.

-Kevin

gocaveman

unread,
Dec 20, 2006, 7:48:07 AM12/20/06
to
BTW - what is the compliment to bwin.minimize() - restore() toFront(),
front()?

Do you happen to have any experience with the Hidden Window Hack?
http://developer.mozilla.org/en/docs/Working_with_windows_in_chrome_code

Thanks again,

-Kevin

Martijn

unread,
Dec 20, 2006, 8:04:31 AM12/20/06
to gocaveman, dev-apps...@lists.mozilla.org
On 20 Dec 2006 04:48:07 -0800, gocaveman <kevin...@bellsouth.net> wrote:
> BTW - what is the compliment to bwin.minimize() - restore() toFront(),
> front()?

Here are the methods you can use on bwin:
http://lxr.mozilla.org/seamonkey/source/dom/public/idl/base/nsIDOMChromeWindow.idl#66
I think you need restore().

> Do you happen to have any experience with the Hidden Window Hack?
> http://developer.mozilla.org/en/docs/Working_with_windows_in_chrome_code

No, but that seems like a hack to store data.
I think Firefox2 and newer versions support the globalStorage property, see:
http://www.whatwg.org/specs/web-apps/current-work/#globalstorage
I've never used it, though.
It's only for html documents it seems, not sure what you should use
for xul documents.

Regards,
Martijn

0 new messages