Bug 339621 - LibreOffice windows and dialogs do not receive focus on open, hiding inside minimised parent instances
Summary: LibreOffice windows and dialogs do not receive focus on open, hiding inside m...
Status: RESOLVED WORKSFORME
Alias: None
Product: kwin
Classification: Plasma
Component: core (show other bugs)
Version: 4.11.11
Platform: Ubuntu Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWin default assignee
URL: https://drive.google.com/file/d/0Bxht...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-03 01:22 UTC by Bernard Gray
Modified: 2015-08-19 12:05 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Sample CSV file from Wikipedia (258 bytes, text/plain)
2014-10-03 01:38 UTC, Christoph Feck
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernard Gray 2014-10-03 01:22:45 UTC
Symptom:
LibreOffice dialogs (such as password prompts, plaintext/csv imports etc) are not made visible if a LibreOffice app is running and minimised - it uses the minimised window as a parent, but does not raise the window to make it visible.

This causes a fairly severe usability issue, where it seems like LibreOffice has crashed, since nothing seems to happen when you click (and continue to click) to open a file that requires user action on a dialog.

I've replicated the issue in KDE and RazorQT which both use the kde-window-manager

I've tested the following:
Ubuntu 12.04/14.04/14.10 alpha
Debian unstable: with kwin 4.11.12

The issue does not occur in Unity or Gnome.

I made two videos - based on:

Ubuntu 12.04, bog standard install. Add kde via:
  sudo apt-get install kubuntu-desktop

add this ppa: https://launchpad.net/~libreoffice/+archive/ubuntu/libreoffice-4-3
upgrade all libreoffice packages to 4.3.x:
  sudo apt-get install $(dpkg -l | grep libreoffice | awk '{print $2}')

Video 1: Unity Desktop, expected (correct) behaviour
https://drive.google.com/file/d/0BxhtBAYzjZj5V1V1NjRTRVRKZ0E/edit?usp=sharing

Video 2: Logged out of Unity, logged into KDE Desktop - unexpected behaviour, as described by this bug:
https://drive.google.com/file/d/0BxhtBAYzjZj5ODZ2RG1GZHZtUEE/edit?usp=sharing

I've had a bit of trouble finding what to log this against, so there are a couple of related bugs floating around other trackers. I was helped in this (the right?) direction by kde-pepo in the #qt-labs channel, so I'll try and get the others cleaned up and pointing here.

On a side note, this is currently a showstopper for a rollout of ~200 desktops. I'm happy to consider a bounty style encouragement bonus, as a kde donation or otherwise if that will assist in getting the problem solved quickly.

Thanks, 
Bernard Gray

Reproducible: Always

Steps to Reproduce:
1. Create a csv file, save it somewhere in the filesystem, close it
2. Open Libreoffice writer window, minimise it
3. Using a file browser, open the saved csv file 



Actual Results:  
The text import dialog is attached to the minimised Writer window which becomes it's parent, but the Writer window stays minimised with no particular visual clue that anything is happening or waiting for input.

Video:
https://drive.google.com/file/d/0BxhtBAYzjZj5ODZ2RG1GZHZtUEE/edit?usp=sharing

Expected Results:  
Video: 
https://drive.google.com/file/d/0BxhtBAYzjZj5V1V1NjRTRVRKZ0E/edit?usp=sharing
Comment 1 Christoph Feck 2014-10-03 01:38:31 UTC
Created attachment 88932 [details]
Sample CSV file from Wikipedia
Comment 2 Christoph Feck 2014-10-03 02:31:04 UTC
Reproducible with 4.14.1 and LibreOffice 4.3.2.2.

When right-clicking the file, use "Open With > LibreOffice Calc", not Writer.

LibreOffice "demands attention", though, at least the panel unhides. It looks like Unity catches the new dialog on the minimized window, and forces a restore. Should be solvable with a KWin script, e.g.

    workspace.clientAdded.connect(function(client) {
      client.minimized = false;
    });


Bernard, to test KWin scripts, type this in Konsole:

    qdbus org.kde.plasma-desktop /MainApplication showInteractiveKWinConsole

Then an Editor/Output window appears. Paste the above 3-line script there, and click "Execute". Then try to reproduce again.

Thomas might provide an improved and installable version.
Comment 3 Bernard Gray 2014-10-03 05:27:29 UTC
(In reply to Christoph Feck from comment #2)
> Reproducible with 4.14.1 and LibreOffice 4.3.2.2.
> 
> When right-clicking the file, use "Open With > LibreOffice Calc", not Writer.
> 
> LibreOffice "demands attention", though, at least the panel unhides. It
> looks like Unity catches the new dialog on the minimized window, and forces
> a restore. Should be solvable with a KWin script, e.g.
> 
>     workspace.clientAdded.connect(function(client) {
>       client.minimized = false;
>     });
> 
> 
> Bernard, to test KWin scripts, type this in Konsole:
> 
>     qdbus org.kde.plasma-desktop /MainApplication showInteractiveKWinConsole
> 
> Then an Editor/Output window appears. Paste the above 3-line script there,
> and click "Execute". Then try to reproduce again.

Tested and confirmed that workaround fixes the bug

This also seems to work around the issue where opening new libreoffice program windows would open in the background/minimised.

> Thomas might provide an improved and installable version.

Fantastic news - thanks for the unbelievably quick response :)
Comment 4 Thomas Lübking 2014-10-03 11:20:48 UTC
The behavior is deliberate (manage.cpp:~465 "// If a dialog is shown for minimized window, minimize it too") and likely intended to prevent the user from interruptions of minimized windows (the WM cannot decide whether this is spontanous or required) until the user moves focus to this window again.

You will also notice that LOo does not unminimize nor (attempt) to gain focus if you open a *.ods (which does not require a conversion dialog)

More interestingly, though the dialog is initially modal for the present window, it opens a new window with the csv (here at least), ie. the transiency and modality seems questionable in the first place.

-----

My suggestion would thus be to rather "fix" the "libreoffice" script to either map/raise/activate the mainwindow when opening a new document?

Something like

if [ -e "$2" ]; then
   wmctrl -x -a libreoffice
fi

on the head of /usr/lib/libreoffice/program/soffice ?
Comment 5 Thomas Lübking 2014-10-03 11:42:46 UTC
For general discussion on the topic of modal dialogs aligning to the mapping state of their leader, please see bug #339635
Comment 6 Martin Flöser 2014-10-06 10:04:00 UTC
given that the window is marked as demands attention I consider this as the expected behavior.
Comment 7 Bernard Gray 2014-10-06 21:43:45 UTC
Thanks for the detailed replies folks, at the very least I have the option of implementing some of my own patches for now if required -
Comment 8 Bernard Gray 2014-10-08 21:58:48 UTC
Once again, thanks for the quick follow up and various detailed workarounds. I've implemented a kwin script for now.
I've also arranged a donation to the KDE e.V. (to say thanks another way!)
Comment 9 Thomas Lübking 2014-10-09 08:47:19 UTC
http://kde-look.org/content/show.php?content=167372

The script only applies to transient dialogs and unminimizes the main window as well to ensure context.
Comment 10 Murz 2015-02-20 09:46:17 UTC
Thomas Lübking, thanks for the script, but it not solve this issue fully.
Maybe we can extend it via auto move focus to any new LibreOffice window created? Is there any hooks for this event in kwin?
Comment 11 Thomas Lübking 2015-02-20 12:30:33 UTC
(In reply to Murz from comment #10)
> Maybe we can extend it via auto move focus to any new LibreOffice window
> created?

To get an idea what you're talking about: do you rather encounter bug #340915 ? (being -likely- https://bugs.documentfoundation.org/show_bug.cgi?id=75471)
The issue overthere is not about dialogs for minimized windows, but for libreoffice _actively_ denying to take the focus.
Comment 12 Murz 2015-02-20 12:37:39 UTC
Thomas Lübking, thanks for the link, I talking about https://bugs.kde.org/show_bug.cgi?id=340915 issue, so I will go into it :)
Comment 13 dolgener 2015-08-19 10:01:50 UTC
Quite unsurprisingly, the three liner from comment 2 as well as the script http://kde-look.org/content/show.php?content=167372 won't work on Plasma 5, giving
 "Error: ReferenceError: Can't find variable: workspace at line 16"

However, Libre Office's dialogs that do not get focus is really PITA even on Plasma 6 ,-)
Can anyone present an updated version here?
Comment 14 Thomas Lübking 2015-08-19 10:20:13 UTC
The script API didn't change (for KWin 5, no promises for 6 =) and the stock scripts "of course" access the workspace object.

How did you install the script, does it show up in "kcmshell5 kwinscripts" and is it present in ~/.local/share/kwin/scripts/ ?

Did you verify the warning is from the kwin_x11 process and you didn't perhaps install the script to plasmashell (the desktop) - what will of course not work?
Comment 15 dolgener 2015-08-19 12:05:45 UTC
You are right, my mistake was to overlook the choice between "Plasma" and "KWin" that has to be made close to the upper right corner of editor's toolbar. It defaults to "Plasma", and hence the script failed.
After choosing "KWin" it works on Plasma 5, too.