New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 593516 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner: ----
Closed: May 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

Chromium window does not take keyboard focus after opening address from commandline

Reported by harvi...@gmail.com, Mar 9 2016

Issue description

UserAgent: Mozilla/5.0 (X11; Linux i686 (x86_64)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36

Steps to reproduce the problem:
1. Open chromium, few websites in tabs, whatever...
2. Open terminal and execute "chromium http://somesite.com/" from commandline
3. Press CTRL+W (as you would do to close new somesite.com tab)
4. type "echo omg" and enter

What is the expected behavior?
I would expect that after opening new tab from commandline chromium would acquire focus. ctrl+w would close browser tab and "echo omg" would go to browser (if there are some tabs left).

What went wrong?
Instead of this ctrl+w and "echo omg" goes to terminal. Even if terminal is on background and browser is maximized on top.

This is really annoying as it does the same eg. when i click on the link in IM (Pidgin in my case). I receive link on image (http://somesite/someimage.jpg), i click on it and pidgin opens chromium and displays the image. after i've seen enough of the image i proceed to press ctrl+w which should close the tab with image. BUT IT CLOSES THE PIDGIN TAB INSTEAD!!! At this time i don't know that pidgin closed the tab at background, but i just wonder why chromium tab was not closed. So i may pres ctrl+w few more times (closing few more tabs in background pidgin!). This have been annoying me for years. Please fix it.

BTW i use XFCE4, but it should not matter. Other apps acquire keyboard focus correctly.

Did this work before? No 

Chrome version: 49.0.2623.75  Channel: n/a
OS Version: 
Flash Version: Shockwave Flash 20.0 r0
 
Cc: thestig@chromium.org e...@chromium.org sadrul@chromium.org
Status: Available (was: Unconfirmed)
It appears the issue is in X11DesktopHandler::ActivateWindow

We set the timestamp to the time the user last clicked or pressed a key in the window:
xclient.xclient.data.l[1] = wm_user_time_ms_;

So, if the user uses the command line to open a new tab in an existing browser, this timestamp becomes out of date and the WM (in my case, Cinnamon) ignores the request.

The other option is to use XRaiseWindow() instead, which I've verified to work in this case.  However, this would steal the focus, even if the user has focus-stealing off in whatever WM they're using.

Another option could be to use 0 for the timestamp, which seems to work on Cinnamon, but would contribute to this bug https://bugs.chromium.org/p/chromium/issues/detail?id=379615.  We shouldn't use the current system time because the timestamp is relative to when the X server started.

Comment 2 by e...@chromium.org, Apr 18 2016

IIRC, when you use the command line to interact with an existing browser, it sends an ipc over a pipe. Can you push the current user time from the instance of chrome on the command line to the long lived chrome process?
I agree that would be the right thing to do.  But, the short-lived chrome process doesn't have the time from the X server stored in wm_user_time_ms_ because the user never gets a chance to interact with the browser.  Also, the timestamp given by the X server is relative to when the X process started, so we can't just use gettimeofday() or similar.

Is there any way to ask the X server for the timestamp, or is there a timestamp that might be stored somewhere that I don't know about?
Project Member

Comment 4 by bugdroid1@chromium.org, May 17 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ca3656dc321be956db788c5fc8ee16cd20ed6d86

commit ca3656dc321be956db788c5fc8ee16cd20ed6d86
Author: thomasanderson <thomasanderson@google.com>
Date: Tue May 17 02:02:50 2016

X11: Better timestamp handling for _NET_ACTIVE_WINDOW

Main changes introduced:
1. Get the X server timestamp in the newly created browser process and
send it over IPC to the old process to update wm_user_time_ms

2. Add logic in set_wm_user_time_ms to avoid setting the time to 0 (or
backwards)

3. If wm_user_time_ms == 0 and we try to activate a window, grab the
server time first

BUG= 593516 , 608521 , 379615 

Review-Url: https://codereview.chromium.org/1949393007
Cr-Commit-Position: refs/heads/master@{#394018}

[modify] https://crrev.com/ca3656dc321be956db788c5fc8ee16cd20ed6d86/chrome/browser/chrome_browser_main_extra_parts_x11.cc
[modify] https://crrev.com/ca3656dc321be956db788c5fc8ee16cd20ed6d86/chrome/browser/ui/startup/startup_browser_creator.cc
[modify] https://crrev.com/ca3656dc321be956db788c5fc8ee16cd20ed6d86/chrome/common/chrome_switches.cc
[modify] https://crrev.com/ca3656dc321be956db788c5fc8ee16cd20ed6d86/chrome/common/chrome_switches.h
[modify] https://crrev.com/ca3656dc321be956db788c5fc8ee16cd20ed6d86/tools/metrics/histograms/histograms.xml
[modify] https://crrev.com/ca3656dc321be956db788c5fc8ee16cd20ed6d86/ui/events/platform/x11/x11_event_source.cc
[modify] https://crrev.com/ca3656dc321be956db788c5fc8ee16cd20ed6d86/ui/events/platform/x11/x11_event_source.h
[modify] https://crrev.com/ca3656dc321be956db788c5fc8ee16cd20ed6d86/ui/views/widget/desktop_aura/x11_desktop_handler.cc
[modify] https://crrev.com/ca3656dc321be956db788c5fc8ee16cd20ed6d86/ui/views/widget/desktop_aura/x11_desktop_handler.h

Status: Fixed (was: Available)

Sign in to add a comment