windowMenu: Check if monitorIndex is valid before using it

Calling meta_window_get_monitor on an unmanaged window may return
-1, so we need to check the return value.

https://bugzilla.gnome.org/show_bug.cgi?id=788882
This commit is contained in:
Sam Spilsbury 2017-10-11 18:42:04 +08:00 committed by Marco Trevisan (Treviño)
parent 5fe349d5ba
commit c9bf72c5c4

View File

@ -128,10 +128,9 @@ var WindowMenu = new Lang.Class({
let screen = global.screen;
let nMonitors = screen.get_n_monitors();
if (nMonitors > 1) {
this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
let monitorIndex = window.get_monitor();
if (nMonitors > 1 && monitorIndex >= 0) {
this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
let dir = Meta.ScreenDirection.UP;
let upMonitorIndex =