Ubuntu

[window management] Alt tab does not switch to the desired application but instead set the urgency flag on the window

Reported by Jendrik Seipp on 2011-03-15
136
This bug affects 27 people
Affects Status Importance Assigned to Milestone
unity-2d
Critical
Michał Sawicz
unity-2d (Ubuntu)
Medium
Thomas Thurman

Bug Description

When a window is selected with alt-tab, it is not opened, but its icon wiggles. Selecting the window with the mouse works.

Using unity-2d maverick ppa.

Florian Boucault (fboucault) wrote :

Thanks for reporting the issue Jendrik.
Is it something you can reliably reproduce? If so, can you share the steps you follow to reproduce?
Do you think it would be possible for you to test on Ubuntu Natty with the same PPA?

summary: - Alt tab does not switch to the desired application
+ [window management] Alt tab does not switch to the desired application
+ but instead set the urgency flag on the window
Changed in unity-2d:
importance: Undecided → High
status: New → Incomplete
Changed in unity-2d:
milestone: none → 3.10
Jendrik Seipp (jendrikseipp) wrote :

I could not test this in natty yet. The error occurs less often now (due to a recent unity-2d update probably). However I can reproduce it with the following steps:

- Open Thunderbird.
- Create new message
- Press Ctrl-Tab

Expected: Main thunderbird window opens.
Actual behaviour: Compose window stays open and thunderbird icon wobbles on the left side.

Using up-to-date package from Maverick PPA.

Florian Boucault (fboucault) wrote :

Thanks again Jendrik.
I tried these steps on my Natty installation and it does not cause that problem.

Tiny remark: I guess you meant "Press Alt-Tab" in the third step instead of "Press Ctrl-Tab", right?

Tiny remark: I guess you meant "Press Alt-Tab" in the third step instead
> of "Press Ctrl-Tab", right?
yes :)

Olivier Tilloy (osomon) wrote :

I cannot reproduce the issue on Maverick with the steps described in comment #2.
@Jendrik: can you still observe the issue?

Jendrik Seipp (jendrikseipp) wrote :

Yes, the steps still work for me. Also the issue seems to be occuring more often again although I can't give other precise steps.

In my case, I'm browsing the internet, and switch to empathy to talk with my
friend, go back to the browser, and when I want to switch other time, it
doesn't switch

2011/3/28 Olivier Tilloy <email address hidden>

> I cannot reproduce the issue on Maverick with the steps described in
> comment #2.
> @Jendrik: can you still observe the issue?
>
> --
> You received this bug notification because you are a direct subscriber
> of a duplicate bug (741746).
> https://bugs.launchpad.net/bugs/735205
>
> Title:
> [window management] Alt tab does not switch to the desired application
> but instead set the urgency flag on the window
>
> Status in Unity 2D:
> Incomplete
>
> Bug description:
> When a window is selected with alt-tab, it is not opened, but its icon
> wiggles. Selecting the window with the mouse works.
>
> Using unity-2d maverick ppa.
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/unity-2d/+bug/735205/+subscribe
>

Olivier Tilloy (osomon) wrote :

I can reliably reproduce with the following steps:

1) Open chromium-browser on a given workspace
2) Move to another workspace, and open thunderbird
3) In thunderbird, open an e-mail that has a link, and click on this link
4) Alt-tab to move to the chromium window (it is requesting attention)

This issue is in fact a consequence (but not a duplicate) of bug #677216.

Changed in unity-2d:
status: Incomplete → Confirmed
Jani Monoses (jani) wrote :

FYI I have always seen this when trying to al-tab away from a chromium window. I however do not use multiple workspaces.
Once there's one icon wiggling, alt-tab does the same to other icons as well, it does not remedy itself unless pressing Super/Esc and various combinations of making the sidebar go away/come back, or by clicking on one of the icons to switch to an app.

Changed in unity-2d:
milestone: 3.10 → none
Jani Monoses (jani) wrote :

@Olivier, is it certain this is a consequence of bug #677216 ? I use all apps in the same workspace.
This is more annoying in Unity-2D than it probably is in classic GNOME because a pulsating taskbar item is less visually demanding than an icon that wiggles, but mostly because here the slider comes up and covers the leftmost part of the current window and does not go away until clicked. Since default GNOME panel layouts are not using autohide and on the left positioning the bug is less of an issue there. I get this behaviour almost every 10 minutes or so (you can tell I am multitasking too much ;)
Any way to debug this to be sure it is a WM issue? Are bamf dbus messages a clue as to what is happening?

Olivier Tilloy (osomon) wrote :

@Jani: thanks for the testing and feedback. I now manage to reliably reproduce the issue with firefox and tomboy open on the same workspace: clicking a link in an open tomboy note will open the page in firefox but doesn’t bring the firefox window to the front, setting its urgency flag instead.

Olivier Tilloy (osomon) wrote :

Sorry, ignore my last comment, the issue is about Alt-tab not changing the active window, which is far more annoying.

Jani Monoses (jani) wrote :

Now finally I can reproduce it
Anytime I follow a link in chromium and then press alt-tab it happens.

Jani Monoses (jani) wrote :

This only occurs with metacity. I tried mutter and xfwm4 and they both behave fine wrt this particular issue.

Olivier Tilloy (osomon) wrote :

@Jani: does this also happen in a classic gnome session with metacity? In other words, is it unity-2d not playing well with metacity, or just an issue in metacity itself?

Jani Monoses (jani) wrote :

I never experienced this in classic gnome, and have been running that until about 3 weeks ago when I tried Unity-2D.

Olivier Tilloy (osomon) wrote :

Very interesting, thanks for the quick feedback. So that means that unity-2d likely doesn’t interact correctly with metacity when requesting to activate windows.

Jani Monoses (jani) wrote :

I experienced this bug only once outside of chromium. Other than that it happens when switching away from chromium after opening a link in a new tab, but it is always reproducible, regardless of which window I would switch to. I only use official ubuntu packages. Now Oneiric but it happened on Natty too as well.

Jani Monoses (jani) wrote :

It is this bug in metacity the workaround of which causes our issue.
https://bugzilla.gnome.org/show_bug.cgi?id=166395

This particular code in metacity is even referenced in unity-2d sources at the top of
launcher/UnityApplications/launcherapplication.cpp
"

Window managers tend to respect orders from pagers to the letter by for
   example bypassing focus stealing prevention. Compiz does exactly that in
   src/event.c:handleEvent(…) in the ClientMessage case (line 1702). Metacity
   has a similar policy in src/core/window.c:window_activate(…) (line 2951).
"

There are too small timestamps on NET_ACTIVE_WINDOW messages (of around March 31992 ) which trigger this response from metacity. Commening that piece in metacity out no longer sets the urgency hint.

The metacity debug logs show a lot of warnings - first chromium having such a small timestamp (which I am not sure why it affects windows that we switch to from chromium) then buggy pager sending timestamp 0 (Unity=2D sets the constant CurrentTime in quite a few places, which is 0), and also 0 timestamp send for switch workspace(both places when
wnck_workspace_activate() is called, a timestamp of 0 is used.
 I am not sure which of these causes the issue, it may be a combination.

Example snippet from metacity log:

Window manager warning: Received a NET_CURRENT_DESKTOP message from a broken (outdated) client who sent a 0 timestamp
Window manager warning: Buggy client sent a _NET_ACTIVE_WINDOW message with a timestamp of 0 for 0x249a5f9 (jani@parap)
Window manager warning: meta_window_activate called by a pager with a 0 timestamp; the pager needs to be fixed.

Changed in unity-2d:
importance: High → Critical
Jani Monoses (jani) wrote :

This is not related to CurrentTime timestamps used in Unity-2D after all. The issue is just more apparent when the launcher slides in and icons wiggle as it gets your attention.
But it is an issue with metacity as even if I kill the launcher the behaviour (not switching to the desired window) persists, just that
there is no urgency notification.
So it is an annoying issue, which I fixed locally by uncommenting the metacity snipped that sets urgency hints for non-zero invalid timestamps in NET_ACTIVE_WINDOW messages, but may not be related to Unity-2D after all.

Didier Roche (didrocks) on 2011-05-31
Changed in unity-2d (Ubuntu):
status: New → Confirmed
Jani Monoses (jani) wrote :

I can only reproduce the behaviour if I launch Chromium from the launcher.
If it is started from the command line it does not trigger the issue and alt-tab switching works well.

Jani Monoses (jani) wrote :

Assigning to Thomas, to at least have a look as the issue is partly due to metacity being stricter than other WMs.

Changed in unity-2d (Ubuntu):
assignee: nobody → Thomas Thurman (marnanel)
importance: Undecided → Medium
milestone: none → ubuntu-11.10
Sabin Iacob (iacobs) wrote :

I was thinking it is focus stealing prevention gone astray as well

in my case (Natty, unity-2d PPA) I trigger this behaviour when:
* I click a link in chromium and immediately press alt+tab to bring up the terminal in order to see something logged
* I am writing an email (thunderbird) and press alt+tab to see something in another window
* I am editing some text somewhere - pidgin, libreoffice, chromium or firefox url bar - and I press alt+tab

some means of configuring / disabling focus stealing prevention would be great IMO

Jani Monoses (jani) wrote :

This makes Unity2d annoying to use if you have Chromium as almost every alt-tab triggers the bug.
I've (hopefully temporarily) switched to an xfce session for now.
Could this get a higher prio, the metacity workaround solved the issue, without a clear downside - after all the other WMs do not do the same check.

Changed in unity-2d:
milestone: none → 4.4
Didier Roche (didrocks) on 2011-09-01
Changed in unity-2d:
milestone: 4.4 → 4.6
Didier Roche (didrocks) on 2011-09-08
Changed in unity-2d:
milestone: 4.6 → 4.8
Changed in unity-2d:
assignee: nobody → Michał Sawicz (saviq)
Michał Sawicz (saviq) wrote :

I've been investigating this a little bit more and here are my experiences:

The easiest way to reproduce:
1. start firefox
2. start terminal
3. execute `gnome-open http://launchpad.net/`
4. single Alt+Tab back to the terminal
5. multiple Alt+Tabs to another app

Expected result:
post-3. firefox is raised and gains focus
post-4. terminal is raised and gains focus
post-5. another app is raised and gains focus

Actual result:
post-3. firefox is raised, but focus remains with terminal
post-4. firefox was never actually the active window, so Alt+Tab tries to switch to firefox, but well... it's raised, right? so nothing actually happens
post-5. another app gets urgent

All in all, after also talking to @jassmith it seems like a focus stealing prevention issue. It shows itself whenever a window tries to raise _itself_ - when clicking a link outside of the browser or similar. I'll be digging in metacity to find out what's what and also try to reproduce outside of unity.

Michał Sawicz (saviq) wrote :

With chromium it's even more apparent... not so with chrome, though... It looks like chromium, whenever opening a new tab, even within the same window, tries to raise itself or does something funky and so trying to switch to any other app, the other app gets urgent.

Jani Monoses (jani) wrote :

Michał, if you missed it, please see comment #19 where the workaround in metacity is discussed.

Michał Sawicz (saviq) wrote :

@jani: the problem is that the bug is most probably _in_ metacity, so unless the workaround got removed from it at some point, it doesn't work anymore, but I've seen it and will investigate further.

Jani Monoses (jani) wrote :

It worked for me by removing that extra check in metacity that no other WM seems to make.

Michał Sawicz (saviq) wrote :

Okay, so... if I understand what you mean, that's what you did:

Index: metacity-2.34.1/src/core/window.c
===================================================================
--- metacity-2.34.1.orig/src/core/window.c 2011-09-13 12:37:46.240667605 +0200
+++ metacity-2.34.1/src/core/window.c 2011-09-13 12:39:41.850668035 +0200
@@ -3043,7 +3043,7 @@
    * honor 0 timestamps for pagers.
    */
   can_ignore_outdated_timestamps =
- (timestamp != 0 || (FALSE && source_indication != META_CLIENT_TYPE_PAGER));
+ (FALSE && source_indication != META_CLIENT_TYPE_PAGER);
   if (XSERVER_TIME_IS_BEFORE (timestamp, window->display->last_user_time) &&
       can_ignore_outdated_timestamps)
     {

That does solve the "urgent instead of switch after alt+tab" issue, but for me it doesn't solve the more important one - window gets raised but doesn't get focus.

After that change the behavior is:

post-3. firefox is raised, but focus remains with terminal
post-4. only now you get switched to firefox
post-5. then works as expected

It does solve the Alt+Tab for chromium, 'cause the chromium window already holds focus and is active. Try executing `chromium-browser http://google.pl/` in a terminal to see what I mean.

Jani Monoses (jani) wrote :

Ok, there may be something I missed. I never encountered the raised but does not get focus behaviour - I assume it is annoying so I would have noticed it if it occured?

Michał Sawicz (saviq) wrote :

So you're not experiencing that? Try running chromium and a terminal on the same workspace, execute `chromium-browser http://google.com/` in the terminal, does Chromium actually get focus? If all is well, you will be able to just type in the google search bar.

OK... And now for something completely different... These problems are only visible when it's unity that's launching the app, as you mentioned. If I run chromium and firefox outside of unity, firefox gets urgent regardless of workspaces, chromium rises and gets focus.

The difference in metacity debug log between the two is:
> Window manager warning: 0x4200044 (Nowa karta) appears to be one of the offending windows with a timestamp of
> 1315914503. Working around...

We're back to unity being at fault, IMO.

Michał Sawicz (saviq) wrote :

@jani could you please try lp:~saviq/unity-2d/fix-launcher-timestamp if it works for you?

Jani Monoses (jani) wrote :

Running ./launcher/app/unity-2d-launcher from this build branch does not expose the issue when I test now a second time - for some reason it did not go well first.
Good work.

Changed in unity-2d:
status: Confirmed → In Progress
Changed in unity-2d:
status: In Progress → Fix Committed
Didier Roche (didrocks) on 2011-09-15
Changed in unity-2d:
status: Fix Committed → Fix Released
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package unity-2d - 4.8.0-0ubuntu1

---------------
unity-2d (4.8.0-0ubuntu1) oneiric; urgency=low

  * New upstream release
    - [window management] Alt tab does not switch to the desired application
      but instead set the urgency flag on the window (LP: #735205)
    - [dash] search field default text not cleared immediately when using
      chinese input method (LP: #745246)
    - [dash] Apps lens shows no result by default (LP: #834571)
    - unity-2d-panel crashed with SIGSEGV in
      IndicatorsWidget::onEntryRemoved() (LP: #846836)
    - [panel] graphics corruption in top line of pixels (LP: #846335)
    - Repeated indicators in unity-2d panel when second screen added
      (LP: #846441)
    - [dash] Lens navigation bar (buttons on lower edge of dash window) is
      accessible (LP: #826560)
    - [dash] Category filters is sorted according to their english names, even
      when another language is used (LP: #838023)
 -- Didier Roche <email address hidden> Thu, 15 Sep 2011 11:43:52 +0200

Changed in unity-2d (Ubuntu):
status: Confirmed → Fix Released
shadow (arnyek) wrote :

I use unity-2d (4.12.0-0ubuntu1), and this bug still here. (Ubuntu 11.10)

Michał Sawicz (saviq) wrote :

@shadow can you describe your exact steps to reproduce, what're your expectations and what're the actual results?

Charles Comstock (dgtized) wrote :

I have also encountered something like this. Using google-chrome on unity-2d (4.12.0-0ubuntu1), frequently when I go to alt-tab from it to either gnome-terminal or emacs, the intended application just flashes in the switcher. I haven't determined exactly what conditions for alt-tabbing away from chrome which triggers this, but it definitely occurs several times an hour. If I can determine exact steps to reproduce I will do so, but thus far I haven't found anything that always reproduces the problem.

I will investigate if it happens regularly after the browser pops up a notification as that sounds related to the previous bug.

Changed in unity-2d:
status: Fix Released → Fix Committed
Gerry Boland (gerboland) on 2011-11-14
Changed in unity-2d:
status: Fix Committed → Fix Released
maxpa (maxpa) wrote :

I still encounter this bug at times even in the 12.04 Beta.

I would love to give instructions to reproduce the issue, but I haven't found a reliable way to do so yet.
It's a very very frustrating bug.

Adam Niedling (krychek) wrote :

This is still happening for me too in 11.10.

Jendrik Seipp (jendrikseipp) wrote :

This bug still happens in 12.04 beta with all updates applied as of today. I cannot find a reliable way to reproduce it, but it seems it only happens when switching to another application from chromium with Alt-Tab.

Changed in unity-2d (Ubuntu):
status: Fix Released → New
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in unity-2d (Ubuntu):
status: New → Confirmed
Mark Campbell (mark.campbell) wrote :

Experiencing this as well in 11.10. *Extremely* annoying. Let me know if you need anything from me: my computer is an open book.

Changed in unity-2d:
status: Fix Released → Confirmed

Still on Ubuntu 12.04, unity-2d 5.12.0-0ubuntu1

Aviram Jenik (q-aviram) wrote :

I am having the same problem described above, almost always with chromium. Precise 12.04, unity-2d 5.12.0-0ubuntu1.
Extremely annoying and a productivity killer.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.