1

I am facing a peculiar problem in Ubuntu 18.04. I have an extended display in office, and I had opened a csv file with libreoffice and viewed it in the extended display, and then closed it that display.

Now I am at home, and have only the laptop display available, and when I am trying to open the same file (or any other csv file) the file is opened but I don't see it on screen. I know the file is opened because in the vertical bar on the left side of screen, I can see the librecalc icon with one red dot on it, and when I right-click on that icon and press "All Windows" then I can see an icon of the file that is opened with its 3 rows of data. Also when I do "ps -ef | grep libre" I can see the process still running.

home/xxx$ ps -ef | grep libre
xxx       7948  1227  0 20:57 ?        00:00:00 /usr/lib/libreoffice/program/oosplash --calc file:///home/xxx/Desktop/desktop_files/try/x1.csv
xxx       7966  7948  1 20:57 ?        00:00:04 /usr/lib/libreoffice/program/soffice.bin --calc file:///home/xxx/Desktop/desktop_files/try/x1.csv --splash-pipe=5

Next day, when at office and the extended display again available, I could now open the same csv file - the application opened up in the extended display. But this time I dragged the application to the laptop display and closed the application there. After that when I opened the csv file again, this time the file opened properly in the laptop display.

So, how do I reset the application, so that it now opens only in the display that is available? Note: The csv file is very small, just about 300 bytes and 3 rows of data, and it opens fine with MS excel or WPS tools.

I dont know whether this problem happens with all applications, but I also noticed it with skype.

NOTE: Jacob asked me to provide information about xrandr, and this is given below. In this scenario, I had closed libreoffice in the extended window, then disconnected that window, and tried to open libreoffice in the laptop window. As usual, the app icon says it is open, but the window is not visible.

$ xrandr
Screen 0: minimum 320 x 200, current 2390 x 768, maximum 8192 x 8192
LVDS-1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
   1366x768      59.97*+  39.97  
   1360x768      59.80    59.96  
   1280x720      60.00    59.99    59.86    59.74  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   1024x576      59.95    59.96    59.90    59.82  
   960x600       59.93    60.00  
   960x540       59.96    59.99    59.63    59.82  
   800x600       60.00    60.32    56.25  
   840x525       60.01    59.88  
   864x486       59.92    59.57  
   800x512       60.17  
   700x525       59.98  
   800x450       59.95    59.82  
   640x512       60.02  
   720x450       59.89  
   700x450       59.96    59.88  
   640x480       60.00    59.94  
   720x405       59.51    58.99  
   684x384       59.88    59.85  
   680x384       59.80    59.96  
   640x400       59.88    59.98  
   576x432       60.06  
   640x360       59.86    59.83    59.84    59.32  
   512x384       60.00  
   512x288       60.00    59.92  
   480x270       59.63    59.82  
   400x300       60.32    56.34  
   432x243       59.92    59.57  
   320x240       60.05  
   360x202       59.51    59.13  
   320x180       59.84    59.32  
VGA-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
VGA-1-2 connected 1024x768+1366+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1024x768      60.00* 
   800x600       60.32    56.25  
   848x480       60.00  
   640x480       59.94  
  1024x768 (0x43) 65.000MHz -HSync -VSync
        h: width  1024 start 1048 end 1184 total 1344 skew    0 clock  48.36KHz
        v: height  768 start  771 end  777 total  806           clock  60.00Hz
  800x600 (0x44) 40.000MHz +HSync +VSync
        h: width   800 start  840 end  968 total 1056 skew    0 clock  37.88KHz
        v: height  600 start  601 end  605 total  628           clock  60.32Hz
  800x600 (0x45) 36.000MHz +HSync +VSync
        h: width   800 start  824 end  896 total 1024 skew    0 clock  35.16KHz
        v: height  600 start  601 end  603 total  625           clock  56.25Hz
  640x480 (0x47) 25.175MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock  31.47KHz
        v: height  480 start  490 end  492 total  525           clock  59.94Hz
$ 
Jacob Vlijm
  • 83,767
R71
  • 131
  • Missed the post. Seems a clumsy workaround, we should be able to create something more convenient. If the issue occurs, what is the output of xrandr in terminal? – Jacob Vlijm May 07 '19 at 12:29
  • @JacobVlijm: xrandr gives a large output, I have added that to the question. – R71 May 09 '19 at 08:12
  • Although you diconnected second screen, xrandr still shows two connected ones: LVDS-1 connected primary 1366x768+0+0 and VGA-1-2 connected 1024x768+1366+0. That seems a bug. What you can try is delete the monitors.config file: https://askubuntu.com/a/749336/72216, in case it is corrupted somehow. Please let me know if that works or not. If not, we can make a convenient workaround. – Jacob Vlijm May 09 '19 at 09:40
  • @JacobVlijm: I dont have any ~/.config/monitors* files. I am using 18.04. Where should this file exist? – R71 May 13 '19 at 07:12
  • in /home/yourname/.config does the command cat ~/.config/monitors.xml not output anything in terminal? – Jacob Vlijm May 13 '19 at 07:30
  • ~ refers to your home directory, so /home/yourname – Jacob Vlijm May 13 '19 at 07:31
  • @JacobVlijm: Thats what I said, that file does not exist for me. I know what '~' means. – R71 May 16 '19 at 08:43

4 Answers4

1

Background process to set on which monitor new windows should appear.
You may run this script when having one monitor, and stop it when more than one. It was written for different purpose, but suits your situation. All regards/upvotes to @JacobVlijm script.
Add some delay before execute, if you put this script in startup apps. Pass monitor name as argument ./script LVDS-1

LeonidMew
  • 2,734
  • 1
  • 21
  • 38
0

I waited for a month, and nobody answered. Then I posted this at launchpad and here is the answer posted there (quoted below). It worked for me.

I recommand reading https://help.ubuntu.com/stable/ubuntu-help/shell-windows.html.en#working-with-windows

According to https://help.ubuntu.com/stable/ubuntu-help/shell-windows-states.html.en you should be able to move the invisible window by selecting it in the task bar, pressing alt+F7, then pressing the arrow keys to move the window to your main screen, and then pressing "enter". If the extended screen is to the right of your laptop screen, then you probably have to use the "left" key.

R71
  • 131
0

Move all windows to the only left over screen with a keypress

What you describe is a bug that occurs on specific hardware. After disconnecting the second screen, it still shows in the output of xrandr as a "phantom" monitor. You should report it.

How to work around?

Although that is the appropriate action, on short term, it won't be much of a help, since this kind of bugs usually live longer than one or two Ubuntu releases.

You found a workaround, but it seems quite a hassle. Alternatively, you can set the script below under a keyboard shortcut. It will move all "normal" windows to the left-over monitor, arranged like in the image below, so ready to pick the window you want to work with:

enter image description here

The script

#!/usr/bin/env python3
import gi
gi.require_version("Wnck", "3.0")
from gi.repository import Wnck
import subprocess

scr = Wnck.Screen.get_default()
scr.force_update()
wins = [
    w for w in scr.get_windows() if
    w.get_window_type() == Wnck.WindowType.NORMAL
]

def get(cmd):
    try:
        return subprocess.check_output(cmd).decode("utf-8".strip())
    except subprocess.CalledProcessError:
        pass

def get_yshift(window):
    """
    windows with property NET_FRAME_EXTENTS are not positioned correctly.
    we can fix that by looking up the top- extent value, add it to the
    targeted y- position.
    """
    wid = window.get_xid()
    xprop_data = get(["xprop", "-id", str(wid)])
    try:
        check = [
            l.split("=")[1].strip().split(", ")
            for l in xprop_data.splitlines()
            if "_NET_FRAME_EXTENTS(CARDINAL)" in l
        ][0]
        y_shift = - int(check[2])
    except IndexError:
        y_shift = 0
    return y_shift

x = 120
y = 70

for w in wins:
    print(w.get_name(), x, y)
    w.unmaximize()
    g = Wnck.WindowGravity.NORTHWEST
    flags = Wnck.WindowMoveResizeMask.X | \
        Wnck.WindowMoveResizeMask.Y | \
        Wnck.WindowMoveResizeMask.WIDTH | \
        Wnck.WindowMoveResizeMask.HEIGHT
    w.set_geometry(g, flags, x, y + get_yshift(w), 200, 300)
    x = x + 90
    y = y + 50

Setup

  1. Copy the script into an empty file, save it as collect_windows.py
  2. Create a shortcut, running the command:

    python3 /path/to/collect_windows.py
    

    (Go to Settings -> Devices -> Keyboard -> Custom Shortcuts, click +)

That's all

Jacob Vlijm
  • 83,767
0

Something similar happens when I resume from suspend and one of the three monitors (usually old monitor #3 replaced last month) is inactive.

I can see in dash that the application is running but the window is not visible.

  • Use Alt+Tab to select the invisible window.
  • Press Alt+F7 to drag the invisible window.
  • The mouse pointer disappears off screen.
  • Move the mouse (without clicking) until an cross mouse pointer appears where I want Window to be.
  • Left-Click and Voila! Window is visible again.

You can try this with visible Windows in a working desktop to experiment.