How do you control what monitor your application opens on?

落花浮王杯 提交于 2019-12-02 22:12:40
Chris Becke

As a windows programmer I control the starting monitor of windows created by my apps by a. storing my apps last position in the registry and restoring that, and b. lacking stored info, setting the starting position to magic flag values that windows uses to position the app using its default logic. The default logic changes from OS to OS as MS improve the user experience, but tend to ensure that the app will open on whatever monitor the user is most likely to be looking at.

As a user with a multi-monitor Windows XP / Vista system I'd use the nVidia desktop manager that has the ability to set starting positions for applications otherwise don't have appropriate behaviour.

From traditional Unix and Linux window manager perspective, you don't control. The window manager handles the positioning of the window.

You may be able to give hints to the window manager, but it should be possible to configure window manager to ignore such things. Moving or placing the window from the program can easily cause pain when a big virtual desktop is in use.

See: http://standards.freedesktop.org/wm-spec/wm-spec-latest.html

One thing to consider is that the monitor configuration might have changed inbetween invocations of the application (e.g., running on a laptop that at times might be docked and uses an external monitor). Make sure that your application is placed in the visible range.

As for APIs, there is the System.Windows.Forms.Screen class that gives you some of that information.

In KDE 4.13.3 (mayby in some olders and newers you can do this (translation may be inacurrate - I use polish version):

  1. run the desired program
  2. right-click on its title bar
  3. choose "more actions"->"additional window settings..." (even more options are under "additional program settings...")
  4. go to tab "size&layout"
  5. Mark checkbox "Screen" and choose "Force" and choose the screen number. Window of this program will be opened always on that screen.

Had a similar problem. Found the following:

Right Klick on the window titlebar and select "More Actions"->"Window Manager Settings". There choose "Focus" in the column to the left. Toggle option "Active screen follows mouse".

If no other defaults are specified, windows appear on the currently active screen. With the procedure described above, mouse position defines this active screen.

Hope that helps,

Best, Bb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!