Linux Mint 20.2

Emacs 27.1

On my desktop computer pluggin 3 monitors.

So I want to open 3 frames on every monitor.

So my steps:

- (desktop-save-mode 1)
- restart Emacs
- Open frame on DP-2
- make-frame-on-monitor, select DP-1
- make-frame-on-monitor, select DP-3

As result on every monitor has one frame.


After restart Emacs I'm suppose that layout of this 3 frames will be restore.

Restart Emacs

And the result is the next:

On DP-1 open 2 frames
On DP-2 open 1 frame
On DP-3 not open frame.

The question is: Does "desktop-save-mode" work for multiple monitors?

1 Answer 1


On Linux it’s not as straight–forward as that.

First, when a program asks the X server for a window the X server must first talk to the Window Manager. The Window Manager can then choose where and how the window should be displayed. Finally, the X server sends information about the new window back to the application that requested it.

This lets users choose a Window Manager that acts how they prefer. For example, some Window Managers ask the user to draw a rectangle on the screen and then place the new window inside it. Others reconfigure all existing windows so that the windows tile instead of overlapping. Some don’t care much, or have only very subtle conventions, such as opening all new windows on the same monitor where the mouse cursor is located.

Second, the X server handles monitors differently than you might expect. Each display handled by the server will have one or more monitors attached to it. The dimensions of the display are only loosely related to the dimensions of those monitors. These days most of the time the dimensions of the display will be the sum of the dimensions of the monitors along one axis, and the maximum of the dimensions along the other. Thus with two 1920×1080 monitors you will generally end up with a 3840×1080 display. However, this is only a default rather than a requirement. The user might configure the monitors to overlap, or to be separated by a gap; parts of the display might go to more than one monitor or to no monitor at all. The display might be larger than can be displayed on the monitors, with the user panning around to view different parts of it. Or it could be smaller than the monitors, and scaled up. The orientation of the monitors might be different than that of the display. These details may or may not change between sessions, or at any time during a session.

The X server normally deals only with coordinates within the boundaries of the display, without reference to the monitors at all. This greatly simplifies things for the applications, because they don’t have to handle any of the complexity if they don’t want to.

When they do want to, they can use an X extension called xrandr to query information about the connected monitors. There is also a command–line tool called xrandr which will do this and print the information out for you; very useful for debugging. Here is an excerpt of what it shows for my simple setup:

Screen 0: minimum 8 x 8, current 3840 x 1080, maximum 16384 x 16384
DVI-I-0 disconnected (normal left inverted right x axis y axis)
DVI-I-1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 509mm x 286mm
DVI-D-0 connected primary 1920x1080+1920+0 (normal left inverted right x axis y axis) 509mm x 286mm

As you can see, my screen is 3840×1080. The monitor attached to DVI-I-1 is 1920×1080 and it’s upper–left corner is located at 0×0 in the display. The other monitor, connected to DVI-D-0, is also 1920×1080 but is located at 1920×0 in the display. This puts them side–by–side with no gap between them.

What make-frame-on-monitor does is platform dependent, but on Linux with X windows it queries xrandr for the list of monitors, asks the user to pick one, then tries to position the new frame within the boundaries of that monitor. However, once this is done Emacs remembers only the position of the frame, not which display it is supposed to be associated with.

You can see this by opening up your desktop save file and looking at the frame parameters stored within. You’ll find something like this:

… (left . 1919) (top . 26) (display . ":1") (pixel-width . 1920) (pixel-height . 1024) (fullscreen . maximized) (visibility . t) …

Although the details may of course be quite different on your computer.

When desktop-save-mode goes to restore the frames, it does use that saved position to try and place the windows at their correct location. However, the Window Manager does not have to allow this. For example, most will at least try to prevent windows from being moved past the edges of the display, and a tiling window manager might refuse to allow the window to move at all. You should look into how the Window Manager that you are using is configured. It may have many knobs you can tune to get exactly the behavior you prefer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.