10

[Terminologies] Let's say "display" = "monitor" = "screen".

Note: Current display (or current monitor, screen) means the display in which the mouse pointer locates, and/or the display showing the current keyboard focused window. For easier discussion we could assume they are the same, i.e. mouse pointed display = keyboard focused display.

In a common Linux XWindows Manager/Desktop Environment, a normal way to move a window to a different screen is first placing the mouse pointer to the target window, clicking on the title bar and then draging it to the destination monitor, since the monitors form a virutal view port.

The quetsion is that, do we currently have a solution (via some software?) to move a window from the other window, without seeing that window? For example, alt-tab can loop through all windows, even those windows not in the current display. So, if it could offer a right-click menu "move to the current display" after the tab-loop-thru, that would be a good solution. Unfortunately it does not, currently.

--UPDATE--

To make things clear, I have a laptop with 2 external monitors, so there are total 3 monitors. I want to use only the 2 external monitor. However, probably due to the driver issue, if I close the lip or just configure to disable the internal monitor, one of the external monitor will be gone. It forces me to keep the internal monitor on and configured. But the internal monitor, i.e. the laptop, was placed far away, so that it's hard for me to look at the screen.

If, a window is accidentally assigned to that monitor, I have no way to get it back, except to move my body/head to see that monitor, and use the mouse to drag the window back to one of my two external monitors.

6
  • 14
    This question is not complete because Linux (as in the kernel) is not responsible for this. It depends wholly on the desktop environment / window manager you're using, which you didn't mention in your question.
    – Compizfox
    Sep 6, 2022 at 14:30
  • Would this be the equivalent of using the right-click Move and arrow keys trick on Windows to get a window from offscreen back onscreen? Sep 7, 2022 at 3:44
  • @music2myear: Not exactly. Since it's totally off the screen, how do you right-click on that window?
    – Robin Hsu
    Sep 12, 2022 at 2:27
  • @Compizfox: First of all, the post is a real problem I faced, and I post the problem as is. At first, there is no assumption that the solution will depend on desktop environments. In addition, I am happy that this question can get many answers which could be a good resource for later readers having the same problem (or other problem but could be solved in one of the answers.)
    – Robin Hsu
    Sep 12, 2022 at 2:42
  • @RobinHsu you misunderstand. In Windows when an application is stuck off the visible window you bring up the window preview thumbnail in the Taskbar and right click on THAT and choose Move, and then you can use the arrow keys to move an offscreen application window back onscreen. Further, Compiz didn't say the problem didn't happen, but that the problem is not with the Linux OS because of how that system works. Linux doesn't have a GUI. You must install software to give Linux a GUI and THAT software will be where the problem and solution are. Please read replies carefully. Sep 12, 2022 at 3:36

7 Answers 7

13

It depends on the particular X window manager that you're using. Some of them may already have keyboard shortcuts for that, e.g. KDE's KWin lets you create a hotkey for moving the focused window between monitors.

When that's not available, you can get an external program such as ewmh-m2m for moving windows between monitors and assign a hotkey to launch that program.

(A window manager could offer this option in its Alt+Tab screen; I don't know any which currently do that, but "move window to mouse pointer when tabbed to" could be added to your preferred WM easily.)

3
  • ewmh-m2m is good catch. I will read the manual. As for moving the focus window: I know how to move the focused current window in the current monitor to the other monitor. I am asking the other way around: I want to move a window at the other monitor, from actions sole by keyboard or mouse on the current monitor. (i.e. move the window on the other monitor thru operations solely on the current monitor.) You are not allowed to go to the other mointor (and click the mouse to focus a window).
    – Robin Hsu
    Sep 6, 2022 at 6:11
  • You can focus it using the keyboard via Alt+Tab, then? Sep 6, 2022 at 6:12
  • 1
    In Gnome it defaults to Win+Shift+Arrow for moving the active window between screens.
    – jaskij
    Sep 6, 2022 at 14:07
5

Found a solution:

In Cinnamon, an taskbar (panel) applet called "Expo" can show a thumbnail virtual workspace, contains all your worksapces and each workspace contains all your monitors.

Within this miniatured view of the workspaces, in each miniatured monitor, it shows a miniatured windows. We can just drag and drop the window from any monitor of any workspace to any other monitor of any workspace on this miniatured worksapces view.

2
  • Hi, add a link to the app, Expo is a widely used word :-).
    – Hastur
    Sep 6, 2022 at 10:57
  • 1
    Edited. I meant the Cinnamon taskbar (or "Panel") applet "Expo".
    – Robin Hsu
    Sep 6, 2022 at 12:07
3

I use XFCE, and do this quite frequently if my 2nd monitor is turned off. This is very much a secondary monitor, and all open windows are shown in the panel at the top of the primary screen.

At the top of the primary screen first left click the title of the window you want (to bring it to the front, so you can see where it ends up), then right click it and click "move". The mouse cursor jumps to the middle of the window, and you can move the mouse to move the window. bumping the cursor against the top of the screen allows you to maximise the window.

A very similar approach has been used in many window managers over the years, and not just in Linux - a similar "move" option has been in Windows for decades.

1
#!/usr/bin/env bash
    #20221221 2008 est EJR
    #xfce monitor mover
     #= CUSTOM SHORTCUT COMMANDS==
      # MONITOR 1
       # bash -ic 'e-monitormover.eb 1'
      # MONITOR 2
       # bash -ic 'e-monitormover.eb 2'
    opt=$1
    case $opt in
    1) xdotool getactivewindow windowmove %@ 0 0;;
    2) wx=$(echo $(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/') | sed -r 's/x.*//')
       xd=$(( wx / 2 ))
       xdotool getactivewindow windowmove %@ "$xd" 0
    ;;
    *);; esac

This File

0

If you see any chance of placing the mouse pointer over that window without seeing that window, you could try one of the oldest, almost forgotten methods of moving a window in X:

Place the mouse pointer anywhere on a window, hold Alt on your keyboard, then click and drag the window into a visible screen area.

You may miss small windows, but grabbing maximized windows should not be a problem. (Also, I'm not sure if this combination is available in all current window managers/desktop environments by default. In Plasma, it still works.)

0

There might be easier, less intrusive ways of doing what you want, but maybe using a tiling window manager could help? They have a lot of functionality that makes it easy to move a window from screen 1 to screen 3, without it every having to be visible in screen 2. There's no dragging of windows with the mouse, so there's also no risk of accidentally moving it to a visible area.

i3wm is one example of a tiling window manager that I would recommend (I personally use it on all my devices)

0

Inspired by user1686's answer metioning the command line tool ewmh-m2m, I found another userful tool, xdotool, for the situation.

The following command moves all windows to (0,0).

xdotool search ".*" windowmove %@ 0 0

It works since in my arrangement, (0,0) is the top left corner of my 1st external monitor.

xdotool could specifically move a certain window (by search). But ".*" is enough for me. It moves all windows, including those already in my two external monitors.

It is really useful when sometimes I traveled with the laptop (and thus no external monitors), all windows will come to the internal monitor. When I am back home, they will keep staying in the internal monitor. This command summons all windows to my 1st external monitor.

xdotools is an X11 tool, which is indepedent to any desktop environment. (As long as it's an X11 Windows system)

--update --

In fact, xdotool offers more: it has getwindowgeometry and getwindowname fuctionalities. One can check if a windows geometry coordinations, (say the center point of the window) are within the 3rd monitor's range. Only move those windows fits the criterion.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .