Bug 31916 - window.focus() does not raise tab
Summary: window.focus() does not raise tab
Status: RESOLVED WORKSFORME
Alias: None
Product: konqueror
Classification: Applications
Component: khtml ecma (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR major
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
: 36652 57777 58587 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-08-31 21:18 UTC by Jo Schulze
Modified: 2006-11-05 03:48 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
kjs_patch.txt (648 bytes, patch)
2002-09-23 23:43 UTC, Simon Hausmann
Details
patch for CVS-HEAD, please review (759 bytes, patch)
2003-04-22 16:57 UTC, Ferdinand Gassauer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jo Schulze 2001-08-31 21:10:00 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           kjs
Version:           KDE 2.2.0 
Severity:          normal
Installed from:    SuSE RPMs
Compiler:          Not Specified
OS:                Linux
OS/Compiler notes: SuSE 7.2pro

window.focus() does not raise the window to the top.
eg. a window with
<body onLoad="this.focus">
causes other windows to lose the focus but when behind other windows it stays there ... unvisible :-(

(Submitted via bugs.kde.org)
Comment 1 Timo A. Hummel 2002-09-19 00:00:33 UTC
I think we should change the behaviour, if it still exists.

From the Netscape Documentation Server:


Description
Use the focus method to navigate to a specific form element, window, or frame,
and give it focus. You can then either programmatically enter a value in the
form element or let the user enter a value. Giving focus to a window brings the
window forward in most windowing systems.

    Note 

    On some platforms, the focus method gives focus to a frame but the focus is
not visually apparent (for example, the frame's border is not darkened). Please
see the release notes (after starting Netscape, choose Release Notes from the
Help menu). 

Comment 2 Pupeno 2002-09-22 22:19:53 UTC
This bug is still present in KDE HEAD from CVS on Sun Sep 22 16:17:14 EDT 2002 
(which means still present in KDE 3.1Beta). 
Comment 3 Simon Hausmann 2002-09-23 23:43:30 UTC
Subject: patch: make window.focus() raise the window

Hi,

According the Netscape docu window.focus() should not only set the
keyboard focus on the specified window but it should also bring it
to the foreground (make it visible) . The attached simple patch does
the trick (see also http://bugs.kde.org/show_bug.cgi?id=31916) .

Ok to commit?

Simon


Created an attachment (id=66)
kjs_patch.txt
Comment 4 David Faure 2002-10-25 11:44:08 UTC
*** Bug 36652 has been marked as a duplicate of this bug. ***
Comment 5 Ferdinand Gassauer 2003-04-18 22:09:52 UTC
try 
http://wetter.orf.at/stm/main 
 
and click on the different villages - a popup with details opens 
click the next village - the former popup reloads with the new date, but stays in the 
background IMHO it should be displayed in foreground 
 
Comment 6 Ferdinand Gassauer 2003-04-22 16:57:44 UTC
Created attachment 1411 [details]
patch for CVS-HEAD, please review
Comment 7 Daniel Molkentin 2003-04-22 18:56:27 UTC
Subject: kdelibs/khtml/ecma

CVS commit by danimo: 

Patch by Ferdinand Gassauer: Properly support window.focus()

CCMAIL:31916-done@bugs.kde.org


  M +3 -1      kjs_window.cpp   1.334


--- kdelibs/khtml/ecma/kjs_window.cpp  #1.333:1.334
@@ -1268,6 +1268,8 @@ Value WindowFunc::tryCall(ExecState *exe
     KHTMLSettings::KJSWindowFocusPolicy policy =
                 part->settings()->windowFocusPolicy(part->url().host());
-    if(policy == KHTMLSettings::KJSWindowFocusAllow && widget)
+    if(policy == KHTMLSettings::KJSWindowFocusAllow && widget) {
+      widget->topLevelWidget()->raise();
       widget->setActiveWindow();
+        }
     return Undefined();
   }


Comment 8 Maksim Orlovich 2003-05-15 05:59:57 UTC
*** Bug 57777 has been marked as a duplicate of this bug. ***
Comment 9 Maksim Orlovich 2003-05-26 05:57:59 UTC
*** Bug 58587 has been marked as a duplicate of this bug. ***
Comment 10 Ferdinand Gassauer 2003-07-06 10:31:11 UTC
Same problem has to be solved if pop up windows show up in tabs instead of 
windows. the tab shoud get the focus. 
cu 
ferdinand 
Comment 11 Ferdinand Gassauer 2003-09-27 04:52:24 UTC
and get the active tab - displayed 
Comment 12 Ferdinand Gassauer 2004-05-10 23:38:29 UTC
changed to major, because normal users expect, that a link (from kmail) opens in an window "on top"
Comment 13 Robert 2004-05-15 15:33:48 UTC
Just reporting that the behaviour (focused tab doesn't get in the foreground) is still existing with konqueror 3.2.2 (gentoo ebuilds).
Comment 14 John D. Hendrickson 2004-07-26 17:06:58 UTC
Regualar users?  Application pop-ups.

I think: follow the window manager rules for focus or stay off the desktop.
Comment 15 Ferdinand Gassauer 2004-07-26 17:18:56 UTC
John: Please explain your comment in detail
Comment 16 Waldo Bastian 2004-10-15 18:36:11 UTC
CVS commit by waba: 

BUG: 31916
Let window.focus() activate tab


  M +2 -1      kjs_window.cpp   1.387


--- kdelibs/khtml/ecma/kjs_window.cpp  #1.386:1.387
@@ -1512,4 +1512,5 @@ Value WindowFunc::tryCall(ExecState *exe
       widget->topLevelWidget()->raise();
       widget->setActiveWindow();
+      emit part->browserExtension()->requestFocus(part);
         }
     return Undefined();


Comment 17 Ferdinand Gassauer 2004-10-16 08:02:32 UTC
Here it "works" only if the tab is activated from another konqueror tab.

It does NOT work if  - for examply - the "bug report" is initialised from another app or a http-link is clicked in kmail.

konqueror stays in the background although the tab gets activated. IMHO not the desired behaviour as described above. one still has to click the taskbar to bring konqueror in the foreground.

cu ferdinand
Comment 18 Paul Sprakes 2004-10-17 17:14:59 UTC
Currently using CVS HEAD and both the konq window and tab get come to the foreground when a link in an external app is clicked (in this case KMail).

Is this now closeable?
Comment 19 Ferdinand Gassauer 2004-10-17 17:26:08 UTC
Here it does NOT work if konqueror is already open and
"open as tab in existing konqueror when URL is called externally" is checked
cu
ferdinand
Comment 20 Paul Sprakes 2004-10-18 14:05:51 UTC
Whats your "focus stealing prevention measures" setting? I had it set to "none" - any other setting will stop konq coming to the foreground (although the taskbar item will flash).

Comment 21 Ferdinand Gassauer 2004-10-18 19:28:33 UTC
Indeed if I change it from "low" to "none" it works for me.

IMHO this is not the desired behavior - If the user actively requests to open a window by clicking a link, the focus stealing prevention should not intercept this. To get the desired behavior this policy has to be turned off and hence is no used any more.
Comment 22 Paul Sprakes 2004-10-19 11:40:27 UTC
Although it doesn't fix this bug, this might get your system working how you want:

In Window specific settings (KControl->Desktop) you should be able to set a separate focus rule for konqueror.
Comment 23 Ferdinand Gassauer 2004-10-19 18:09:49 UTC
Hi!
Thanks for the hint. 

I followed your suggestion and it works the way I think it should.

I found the following entry, which IMHO should be made standard as I feel "non expert" users are definitely not able to set up this behaveour. 

Or this matter should be assigned to the ked-usability group.

kwinrulesrc
[1]
clientmachine=linuxfg04
clientmachinematch=0
description=konqueror accept focus
fsplevel=0
fsplevelrule=2
title=Bug 31916 - window.focus() does not raise tab - Konqueror
titlematch=0
wmclass=Konqueror
wmclasscomplete=false
wmclassmatch=1

cu
ferdinand
Comment 24 Jo Schulze 2004-11-10 23:18:07 UTC
I opened the original bug report, the issue was quit different. It was about pop-up windows and their focus. Now it's about which tab gets the focus.
Personally, I don't really have any idea of a perfect solution. IMHO popups should still be opened as popups unless forced (by reight-click or "open in Tab") otherwise. 
I don't have a suggestion about how to handle this. Don't ask me, I'm out.
Comment 25 Ferdinand Gassauer 2004-11-10 23:31:49 UTC
whatever happens, if the user clicks on a link, the content should be displayed / opened in the appropriate application.
Comment 26 Damir Perisa 2005-10-15 03:37:11 UTC
this bug is now really old (11 months no action)

in the meantime lots of kde versions came out

can we close this one? 
Comment 27 Raphael Wegmann 2005-11-10 21:31:15 UTC
I tried the URL of comment #5 

http://wetter.orf.at/stm/main

which seems to work with konqueror 3.4.2.
Comment 28 Ian Ventura-Whiting 2006-08-29 14:46:46 UTC
This should be closed.
Comment 29 Jo Schulze 2006-11-05 03:48:30 UTC
This is now officially a dead bug.
;)