qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Dongwon Kim <dongwon.kim@intel.com>
To: qemu-devel@nongnu.org
Cc: sweeaun <swee.aun.khor@intel.com>,
	Khairul Anuar Romli <khairul.anuar.romli@intel.com>,
	Vivek Kasireddy <vivek.kasireddy@intel.com>,
	Dongwon Kim <dongwon.kim@intel.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH] ui/gtk: mon_num parameter to specify target monitor for launching Qemu
Date: Thu, 18 Nov 2021 14:51:27 -0800	[thread overview]
Message-ID: <20211118225127.26147-1-dongwon.kim@intel.com> (raw)

Introducing a new integer parameter to specify the monitor where the
Qemu window is placed upon launching.

Monitor index can start from 0 to (total number of monitors - 1).
Default value for the parameter is -1, which doesn't affect anything.

It can be used together with full-screen=on, which will make the Qemu
window full-screened on the targetted monitor.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Cc: sweeaun <swee.aun.khor@intel.com>
Cc: Khairul Anuar Romli <khairul.anuar.romli@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 qapi/ui.json    |  7 ++++++-
 qemu-options.hx |  2 +-
 ui/gtk.c        | 10 ++++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/qapi/ui.json b/qapi/ui.json
index d7567ac866..7552b503b2 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1099,13 +1099,18 @@
 #               assuming the guest will resize the display to match
 #               the window size then.  Otherwise it defaults to "off".
 #               Since 3.1
+# @mon-num:     Indicate monitor where Qemu window is lauched. mon-num
+#               could be any number from -1 to (total num of monitors - 1).
+#               (default: -1: use default monitor)
+#               since 6.2
 #
 # Since: 2.12
 #
 ##
 { 'struct'  : 'DisplayGTK',
   'data'    : { '*grab-on-hover' : 'bool',
-                '*zoom-to-fit'   : 'bool'  } }
+                '*zoom-to-fit'   : 'bool',
+                '*mon-num'       : 'int' } }
 
 ##
 # @DisplayEGLHeadless:
diff --git a/qemu-options.hx b/qemu-options.hx
index 7749f59300..7a888b16b1 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1852,7 +1852,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
 #endif
 #if defined(CONFIG_GTK)
     "-display gtk[,full-screen=on|off][,gl=on|off][,grab-on-hover=on|off]\n"
-    "            [,show-cursor=on|off][,window-close=on|off]\n"
+    "            [,mon-num=<value>][,show-cursor=on|off][,window-close=on|off]\n"
 #endif
 #if defined(CONFIG_VNC)
     "-display vnc=<display>[,<optargs>]\n"
diff --git a/ui/gtk.c b/ui/gtk.c
index d2892ea6b4..8d8aa55822 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2314,6 +2314,16 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
                              vc && vc->type == GD_VC_VTE);
 #endif
 
+    if (opts->u.gtk.has_mon_num && opts->u.gtk.mon_num &&
+        opts->u.gtk.mon_num >= 0) {
+        GdkRectangle mon_dest;
+        if (opts->u.gtk.mon_num < gdk_display_get_n_monitors(window_display)) {
+            gdk_monitor_get_geometry(
+                gdk_display_get_monitor(window_display, opts->u.gtk.mon_num),
+                &mon_dest);
+            gtk_window_move(GTK_WINDOW(s->window), mon_dest.x, mon_dest.y);
+        }
+    }
     if (opts->has_full_screen &&
         opts->full_screen) {
         gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
-- 
2.30.2



             reply	other threads:[~2021-11-18 23:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18 22:51 Dongwon Kim [this message]
2021-11-19  8:53 ` [PATCH] ui/gtk: mon_num parameter to specify target monitor for launching Qemu Philippe Mathieu-Daudé
2021-11-19  9:24 ` Paolo Bonzini
2021-11-19 20:10 ` [PATCH v2] ui/gtk: new param monitor to specify target monitor for launching QEMU Dongwon Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211118225127.26147-1-dongwon.kim@intel.com \
    --to=dongwon.kim@intel.com \
    --cc=khairul.anuar.romli@intel.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=swee.aun.khor@intel.com \
    --cc=vivek.kasireddy@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).