create new tag
, view all tags

Set Focus Stealing Prevention per Window / Application on KDE 3.5

Prevent your web browser from popping up over your email client when you click on a link in an email
Make kmail and konqueror behave
Keep konqueror behind kmail except when you want it in front
Bring your editor to the foreground when invoked from another application

The solution lies in setting the Focus Stealing Prevention level for a specific window or application. Read on...

key phrases: keep above, keep below These phrases are for search engines--neither keep above nor keep below are the solution to this problem, although I made some unsuccessful attempts using those window settings.

I finally resolved the problem I've had since switching from Mandriva 2006 to Debian 5.0 (Lenny).  My specific problem was that I have an instance of konqueror on the same desktop as kmail.  From Mandrake 6.2 (iirc) through Mandriva 2006, I could click a link in kmail and it would open in the instance of konqueror on the same desktop, but leave that instance of konqueror in the background.

After installing Debian, I could not achieve the same behavior until now.

This is the behavior I prefer--I can go through my email clicking on whatever links look interesting, then go to konqueror to review the content of those links.  It was especially helpful when I used a dial-up modem, but, now with broadband, I still prefer this behavior.

The way to resolve this problem is to set Focus Stealing Prevention to High for either that specific konqueror instance (i.e., a specific konqueror instance's main window) or for all konqueror instances (i.e., the konqueror application).  Update: I was concerned that setting it to High for all konqueror instances might cause some problems, but I've had it set for nearly a week and haven't found it to be a problem.

I had begun to get the idea that setting Focus Stealing Prevention to High was the solution, but, at first, I couldn't find the way to set it for only a specific window or application.  Setting it to high for all applications is not desirable as other applications will fail to come to the foreground on a desktop with other open applications.



Other Sources of Problems / Confusion

Make konqueror open new tabs in the background

Recently (ca. 20120119) I've been having a problem that, at least at first, I thought was this problem, and tried to solve it by changing the focus stealing prevention settings.

It turns out that the behavior was a little different--in this case, when I clicked on a link to have it opened on a new tab in konqueror, the new tab came to the foreground / got the focus, which is not the behavior I prefer (nor the behavior that had prevailed until recently (I noticed this, and maybe a recurrence of the focus stealing problem between kmail and konqueror) after a recent reboot--somehow I may have reverted to one or more older configuration files.

The solution to this (in konqueror 3.x) is

Konqueror: Settings -> Configure Konqueror -> Web behavior -> Tabbed Browsing -> Advanced Options: "Open New Tabs in the Background"

Now I have to revert all of the Focus Stealing Prevention settings to their previous values.

Specific Instructions

  • on any konqueror window, right click in the window title bar, then choose Advanced -> Special Application Settings. 

  • if you want to make the change for just one instance of konqueror, from that konqueror window: right click in the title bar, then choose Advanced -> Special Window Settings.  Note that if that specific instance of konqueror crashes or is closed intentionally, you will have to repeat these steps for a replacement instance of konqueror.

  • choose the Workarounds tab

  • click the checkbox to the left of Focus Stealing Prevention, choose Force from the first dropdown menu and High from the second dropdown menu, all on the same line as the checkbox for Focus Stealing Prevention

There were two problems contributing to my initial difficulty:

  1. This setting is not on the same tab as the other settings that would seem to be relevant to this problem, that is, it is not on the Preferences tab with settings like Keep Above, Keep Below, and Set Focus.  Instead, it is on the Workarounds tab.  In other words, at first, I couldn't find a setting for Focus Stealing Prevention for a specific window or application.

  1. Initially, I failed to notice the second dropdown menu on the Focus Stealing Prevention line on the Workarounds tab--somehow I never associated that 2nd dropdown menu with the rest of the line.

Options for this and other window settings

Aside: For other special window settings, for instance, "Keep below" on the Preferences tab, there is a checkbox to the left of "Keep below" and another one to the right of the (single) drop down menu--both of those have to be checked to make Keep below take effect.

I still don't quite understand all the choices on the first dropdown menu, particularly the choices for some other special window settings which may include the following.  The first seems self explanatory, but what are the specific differences between the last five options?:

  • Do Not Affect
  • Apply Initially
  • Remember
  • Force
  • Apply Now
  • Force Temporarily

Maybe those do (or will) make more sense now that I understand how to set the Focus Stealing Prevention level.

Bring your editor to the foreground on opening a file from elsewhere

  • Dominik Stadler did almost the opposite to get Geany to come to the foreground when opening a file for editing from some other application, e.g. file browser, commandline, browser, ..., except he set the Focus Stealing Prevention for Geany to None.

Similar setting for GNOME?

  • I presume there is a similar setting for GNOME--when I or somebody find that, we can add a note here and (perhaps) start a new page.  I have seen some hints that the GNOME Focus Stealing Prevention doesn't work, or doesn't work as well.

Was my problem due to a different window manager?

  • I suspect that the problem occurred in Debian 5.0 because Debian uses kwin as the window manager for the KDE desktop, and, iirc, Mandriva used a different window manager.  Off hand I can't remember the name of that other window manager.  (And, the default settings are apparently different.)

Editing kwinrulesrc to change the setting?

  • This setting can probably be done by editing your ~/.kde/share/config/kwinrulesrc file--here's what mine looks like after making the changes (note: the prefix "fsp" stands for Focus Stealing Prevention).  I say "probably" because there is a chance this is one of those files that should not be edited manually because it gets overwritten by the "application" (in this case kwin) under various circumstances.
Description=Application settings for konqueror
title=back1 - Konqueror

  • BTW, there are several configuration or similar files for kwin in ~/.kde/share/config:

I'm sure the number in that last filename changes for various reasons.

Wish List

  • <hold until I decide whether it is a problem to have all konqueror instances set for high Focus Stealing Prevention--UPDATE: I don't think it is a problem, so I won't really "push" this as a wish list item--I will keep it here "for the record".>  It sounds like it would be nice to make a setting specific for an application and the desktop it's on--e.g., , in my case, the instance of konqueror on desktop #3.

Need to redo the setting if made to only one instance and it crashes

Presumably, if I set Focus Stealing Prevention to High for one specific instance of konqueror, if that instance crashes, or I intentionally close it, I'll have to redo that setting when I create a replacement instance.

So, I've set Focus Stealing Prevention to High for all instances of konqueror, and haven't seen a problem so far.  I was worried that I'd find some objectionable behavior when opening new links within a given instance of konqueror.  I haven't, and thinking about it, I don't think I should--my point being that, konqueror already has the focus, and I can control whether it switches to that new tab with konqueror settings--again, I prefer to stay on the current tab, and switch to the new tab at my convenience._

Fixing problems related to my experimentation to fix this problem

After I got this problem fixed (so that konqueror did not pop-up over kmail), I found some other problems that I think were caused by the various solutions I tried before finding the way to set Focus Stealing Prevention for a specific application or window. Now I think I fixed those as well, and want to record those other settings--all under Configure Window Behavior (i.e., these are general settings for all windows):

  • On the Advanced "panel", set Focus stealing prevention level to Normal
  • On the Focus "panel":
    • Set Policy to "Focus Follows Mouse"
    • Click on "Click raise active window"--if this is grayed out, you may have to switch to a different Policy until you can set this, then switch back to "Focus Follows Mouse"
  • There may be changes to make on the "Actions" panel--I tried some of these and they didn't seem to help the current / new problem.

BTW, the current / new problem was that when I clicked within an open window in the background, it did not accept focus and come to the foreground. (It did if I clicked in the window titlebar.) This was a definite difference in behavior from the way it used to be, and I'm not sure what I did to change it.


  • (rhk) RandyKramer - 2009-09-30
  • If you edit this page: add your name here; move this to the next line; and if you've used a comment marker (your initials in parenthesis), include it before your WikiName.

Revision Comment

  • %DATE% —

Page Ratings

Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r12 - 2012-01-19 - RandyKramer
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiLearn? WebBottomBar">Send feedback
See TWiki's New Look