Bug 85608 - [ViewMgmt] [EditorMgmt] Create option to disable views that open automatically
Summary: [ViewMgmt] [EditorMgmt] Create option to disable views that open automatically
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
: 113109 (view as bug list)
Depends on:
Blocks: 106388
  Show dependency tree
 
Reported: 2005-02-16 17:31 EST by Stefan Xenos CLA
Modified: 2007-05-03 14:37 EDT (History)
13 users (show)

See Also:


Attachments
workbench patch (13.73 KB, patch)
2005-10-13 12:50 EDT, Stefan Xenos CLA
no flags Details | Diff
ide patch (822 bytes, patch)
2005-10-13 12:51 EDT, Stefan Xenos CLA
no flags Details | Diff
Grab Focus v02 (14.57 KB, patch)
2007-02-16 14:12 EST, Paul Webster CLA
no flags Details | Diff
Grab Focus Hooks v01 (6.47 KB, patch)
2007-03-22 14:19 EDT, Paul Webster CLA
no flags Details | Diff
grabfocus plugin 20070325 (4.61 KB, application/octet-stream)
2007-03-25 14:13 EDT, Paul Webster CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Xenos CLA 2005-02-16 17:31:40 EST
Some views (like the console view and formerly the problems view) like to open
automatically in response to some background event.

In order to disable this behavior, it is necessary to hunt down several
preferences from different preference pages to disable the behavior for each view.

There should be a global option that disables any attempt to open a view or
editor from a background thread. For example, any API that brings a view or
editor to the foreground can be disabled unless the SWT event loop is processing
a keystroke or mouse event. These APIs could make the view or editor title flash
or become bold instead of bringing it to the foreground.
Comment 1 Billy Biggs CLA 2005-02-16 18:20:15 EST
Why bother making it a preference, why not just fix these views to not come to
the front?
Comment 2 Nick Edgar CLA 2005-02-17 12:52:55 EST
I think the best we could do here is to provide new API for requesting that a
view be activated, without actually activating it.  The workbench could flash
its tab or whatever.  We could then encourage plugins that want to show a view
from the background to use this new API rather than showView.
Should generalize to editors too.

Darin, do you have any thoughts on how you'd like this to work for the debug case?

Comment 3 Darin Wright CLA 2005-02-17 13:01:21 EST
Your suggestion sounds good. An API to "bring attention" to a view without 
showing it would work.

However, does this conflict with the current "bolding" view title support 
which is used to indicate that content in a view has changed? Currnetly, when 
the user turns off the preference to show the console when there is output, we 
bold the console title via IWorkbenchSiteProgressService.warnOfContentChange
(). Would these features conflict? What would be the rules for choosing 
between the two behaviors?
Comment 4 Stefan Xenos CLA 2005-02-17 15:22:42 EST
I don't have a problem with adding new API that respects a no popups policy.

Note that views can already do a showView(viewId, secondaryId, VIEW_CREATE)
followed by bolding their title. We don't need a new UI affordance. The bold
title is already used to draw the user's attention. Views that jump to the
foreground always do so because their content has changed.

I'd still prefer that the workbench enforce the no-popups policy directly...
more like the FireFox popup-blocker or the windows XP option that prevents apps
from stealing focus. This would guarantee that it is respected universally
without requiring any changes to downstream plugins.

Comment 5 Stefan Xenos CLA 2005-02-17 15:24:54 EST
Re: comment 1

We can't always fix the views because not everyone agrees that this is a bug.
See bug 85596.
Comment 6 Nick Edgar CLA 2005-02-17 23:14:11 EST
Re comment #5: the user owns the focus, so stealing it is always bad.  I suppose
we could try the pop-up blocker approach, but I'm not sure that would be
appropriate for all existing calls to showView.

Re comment #3: I think we'd want the same affordance as warnOfContentChange.
Darin, would you be willing to try using showView(viewId, secondaryId,
VIEW_CREATE) and IWorkbenchSiteProgressService.warnOfContentChange() together as
the default behaviour?  If this works for you, we could then consider whether to
make this the default behaviour for the regular showView if it wasn't triggered
directly by the user.


Comment 7 Darin Wright CLA 2005-03-08 12:55:35 EST
Discussion with the JDT team indicates that we want to continue with the 
current form of operation. I.e. the console should open & display 
automatically when output is written. This is to support new users of Eclipse 
and the their initial development experience (i.e. write a program that 
produces output). The claim is that advanced users can turn the preference off.
Comment 8 Nick Edgar CLA 2005-03-08 13:20:48 EST
I still think it would be worth prototyping the approach suggested in comment
#3, to see if that gives a strong enough cue to new users without stealing focus.
Comment 9 Stefan Xenos CLA 2005-08-03 20:21:25 EDT
The intent of this PR was to make it unnecessary to hunt through the preference
pages to find all options of the form:

"Allow this view to open automatically in situation XXXX"

The addition of the new API does not solve this problem, especially if it is not
universally adopted. Comment 17 indicates that it won't be. Restoring original
summary text.
Comment 10 Stefan Xenos CLA 2005-08-03 20:53:12 EDT
I've added a "Never steal focus" preference (really, it means "never let views
jump to the front uninvited", but I thought the former label was easier to
grok). Here's how it works:

- If the preference is disabled, everything works as it did before.
- As long as Eclipse is responding to a keystroke or a mouse click, everything
works as it did before.
- In any other situation, any attempt to activate a view or bring it to front
will simply result in bolding the tab.

The preference is off by default.
Comment 11 Tod Creasey CLA 2005-08-09 09:11:18 EDT
Reopening. We are going to have to roll this back for 3.1. M1 due to Bug 106388.
Comment 12 Dani Megert CLA 2005-08-10 08:45:48 EDT
Do we really need this preference?
Comment 13 Stefan Xenos CLA 2005-08-13 15:54:01 EDT
Unless we can get universal agreement from all plugin authors to never open a
view or editor automatically (we can't), or to voluntarily respect a global
preference (won't happen either: see comment 7), then we need the preference to
forcibly disable the behavior.

Those of us who find the behavior intolerable REALLY want it.

Steve: The performance issue here looks like an SWT thing. It seems that having
any event filter hooked up to certain events causes a performance regression,
even if the code in the filter is a no-op. I suspect the filter is being called
way too frequently for mousedown filters on tree widgets.

If we're going to bring back the "don't jump to foreground" preference, the
performance issue will need to be fixed.
Comment 14 Steve Northover CLA 2005-08-22 12:08:00 EDT
Veronika and I looked into the performance thing and could not figure out what 
was going on.  We put a print when the notification was sent while the 
directory dialog was up and it wasn't sent 1,000,000 times or anything strange 
like that.  We were literally at a loss to understand what Windows was doing 
and why adding a filter should have anything to do with it ... but it does 
because we could comment out the lioe that installed this feature and the 
performance came back.
Comment 15 Steve Northover CLA 2005-08-22 12:10:06 EDT
>I suspect the filter is being called way too frequently for mousedown
>filters on tree widgets.

The problem was in a directory dialog, not a Tree.  Do you have any reason to 
suspect another (unrelated) problem?
Comment 16 Steve Northover CLA 2005-10-06 15:18:17 EDT
Ok, I think we've fixed the SWT part of this now so you could try it again.  
The problem was we were chewing CPU when an asynchronous message was pending 
(see bug 88958).
Comment 17 Stefan Xenos CLA 2005-10-13 12:50:30 EDT
Created attachment 28240 [details]
workbench patch
Comment 18 Stefan Xenos CLA 2005-10-13 12:51:12 EDT
Created attachment 28241 [details]
ide patch

These two patches bring back the feature.
Comment 19 Stefan Xenos CLA 2005-10-13 12:52:25 EDT
Doug, since you rolled back the original patch, can you inspect this version?
Comment 20 Douglas Pollock CLA 2005-10-14 09:54:47 EDT
I propose the following.  We add a new mode to IWorkbenchPage,    
VIEW_ACTIVATE_IF_ALLOWED.  We add a new workbench preference, "Prevent views   
from taking focus".    
    
    if (preventViewsFromTakingFocus)    
        if (inSameStackAsActivePart)    
            VIEW_ACTIVATE_IF_ALLOWED == VIEW_CREATE    
        else   
            VIEW_ACTIVATE_IF_ALLOWED == VIEW_VISIBLE    
    else    
        VIEW_ACTIVATE_IF_ALLOWED == VIEW_ACTIVATE   
   
I feel this has some advantages over the proposed patch.  It does not change   
the current meaning of any of the API calls, which I believe is better for   
compatibility reasons (i.e., lower risk).  It provides a global switch for   
preventing focus stealing, which can -- by default -- be off (i.e.,   
preventViewsFromStealingFocus=false).  I think this addresses concerns from   
Debug and JDT.  It also means the UI affordance is completely under the 
control of one thing (and, ideally, this is the presentation). 
  
The only problem is, as Stefan points out, this would be an "opt-in" approach.   
If plug-in developers didn't play nicely, then nothing happens.  Within the  
Eclipse SDK this is probably not a problem; we're all friends here.  But in  
the Eclipse world at large this could be problematic.  
  
I think this needs more thought before committing to any one approach.  
 
Comment 21 Ella Belisario CLA 2005-10-19 13:41:25 EDT
*** Bug 113109 has been marked as a duplicate of this bug. ***
Comment 22 Stefan Xenos CLA 2005-10-20 17:40:45 EDT
With the proposed solution, there will still be many situations where views will
grab focus from a background thread. The intention of this PR is to arrange such
that this should NEVER occur. Doug, I asked for a code inspection, not an
opinion on whether you want the feature. If you don't want it, don't enable the
preference.

I was told that there is resistance to this patch because I am the only one
pushing for it. If you are on this CC list because you are in favor of this
feature (or if you have filed a duplicate), please:

1. Comment here saying so.
2. Vote on this PR.
3. Tell your friends to do the same.
Comment 23 Stefan Xenos CLA 2005-10-21 11:25:45 EDT
Reassigning back to myself. I will ask someone else for the code inspection. 

BTW, if anyone wishes to discuss PRs I'm working on, please do so with me present.
Comment 24 Tod Creasey CLA 2005-10-21 12:42:58 EDT
The chance of getting anything universally promised is essentially impossible.
Has this been discussed in the newsgroups anywhere?

If I am not mistaken we are discussing one view in the SDK currently. I agree
with the sentiment that should the debug team agree we could move the preference
to the workbench and allow others to use it but I am concerned that we are going
to break a lot of affordances in other products by doing this.

Generally the approach of willful adoption is safer than forcing a change in
behaviour on plug-ins without thier knowledge,
Comment 25 Michael Van Meekeren CLA 2005-10-26 09:45:26 EDT
The only thing I can think of that somehow walks the careful walk between
forcing change in behaviour and avoiding need for willful adoption is something
like a popup blocker in a browser (although not introduced as if something bad
happened), where the first time a few is brought to the front without the user
causing it, a dialog opens and says "The <view name> view thought you should see
it's contents and hence came to the front, do you want to disable this feature
for the <view name> view in the future?  See ? preferences to re-enable in the
future."  
|Yes| |No| 
[] don't ask me again OR remember my decision
Comment 26 Stefan Xenos CLA 2005-10-26 17:41:25 EDT
Re: comment 25

That looks fine to me.
Comment 27 Paul Webster CLA 2006-09-28 11:00:46 EDT
There are currently no plans to work on this feature.

PW
Comment 28 Stefan Xenos CLA 2006-09-29 19:34:48 EDT
I still find this to be a severe usability problem in Eclipse and Eclipse-based products. I'm still interested in working on this myself if someone will consider committing the patch.
Comment 29 Stefan Xenos CLA 2007-02-12 13:00:05 EST
If this is still under consideration for 3.3, now would be a good time to look at it. :-)
Comment 30 Paul Webster CLA 2007-02-16 14:12:04 EST
Created attachment 59186 [details]
Grab Focus v02

This is just an update to HEAD so it can be used for testing.
PW
Comment 31 Paul Webster CLA 2007-03-22 14:19:53 EDT
Created attachment 61721 [details]
Grab Focus Hooks v01

org.eclipse.ui.tweaklets.grabfocus is in the platform-incubator project, and this is the matching hook patch.

PW
Comment 32 Paul Webster CLA 2007-03-25 14:07:14 EDT
Released to HEAD >20070325

We haven't finalized the deployment for tweaklets, so I'll attach a plugin that can be used for testing.  The actual tweaklet is in platform-incubator/ui/tweaklets/org.eclipse.ui.tweaklets.grabfocus

Stefan, I didn't include a pref.  Boris suggested that if we want one, install a Tweaklet node and the pref page underneath that.  I won't have time to do the pref page, but if you want to tweak the tweaklet (haha) feel free.

PW
Comment 33 Paul Webster CLA 2007-03-25 14:13:39 EDT
Created attachment 61929 [details]
grabfocus plugin 20070325

Drop this in your plugins directory and you'll get the prevent grab focus behaviour.
PW
Comment 34 Paul Webster CLA 2007-05-01 08:33:53 EDT
This is a tweaklet in 3.3

PW
Comment 35 Paul Webster CLA 2007-05-03 14:37:06 EDT
With tweaklet in I20070503-0842
PW