All of lore.kernel.org
 help / color / mirror / Atom feed
From: sweeaun <swee.aun.khor@intel.com>
To: qemu-devel@nongnu.org
Cc: swee.aun.khor@intel.com, khairul.anuar.romli@intel.com,
	eblake@redhat.com, vivek.kasireddy@intel.com, armbru@redhat.com
Subject: [PATCH v2] ui/gtk: Allow user to select monitor number to display qemu in full screen through new gtk display option
Date: Thu, 17 Jun 2021 10:06:09 +0800	[thread overview]
Message-ID: <20210617020609.18089-1-swee.aun.khor@intel.com> (raw)

 -display gtk,monitor=<value>

Signed-off-by: sweeaun <swee.aun.khor@intel.com>
---
 qapi/ui.json    |  4 +++-
 qemu-options.hx |  2 +-
 ui/gtk.c        | 15 +++++++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/qapi/ui.json b/qapi/ui.json
index 1052ca9c38..1616f3ffbd 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1035,13 +1035,15 @@
 #               assuming the guest will resize the display to match
 #               the window size then.  Otherwise it defaults to "off".
 #               Since 3.1
+# @monitor: Monitor number to display qemu in full screen.
 #
 # Since: 2.12
 #
 ##
 { 'struct'  : 'DisplayGTK',
   'data'    : { '*grab-on-hover' : 'bool',
-                '*zoom-to-fit'   : 'bool'  } }
+                '*zoom-to-fit'   : 'bool',
+                '*monitor' : 'int' } }
 
 ##
 # @DisplayEGLHeadless:
diff --git a/qemu-options.hx b/qemu-options.hx
index 14258784b3..e4b89b6a72 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1787,7 +1787,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
     "            [,window_close=on|off][,gl=on|core|es|off]\n"
 #endif
 #if defined(CONFIG_GTK)
-    "-display gtk[,grab_on_hover=on|off][,gl=on|off]|\n"
+    "-display gtk[,grab_on_hover=on|off][,gl=on|off][,monitor=<value>]\n"
 #endif
 #if defined(CONFIG_VNC)
     "-display vnc=<display>[,<optargs>]\n"
diff --git a/ui/gtk.c b/ui/gtk.c
index 98046f577b..84da126611 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2268,6 +2268,21 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
         gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item));
     }
     gd_clipboard_init(s);
+
+    if (opts->u.gtk.has_monitor) {
+        int n_monitor;
+        n_monitor = gdk_display_get_n_monitors(window_display);
+
+        if ((opts->u.gtk.monitor <= n_monitor) &&
+            (opts->u.gtk.monitor > 0)) {
+            GdkScreen *gdk_screen;
+            gdk_screen = gdk_display_get_default_screen(window_display);
+            gtk_window_fullscreen_on_monitor(GTK_WINDOW(s->window), gdk_screen,
+                                             (opts->u.gtk.monitor - 1));
+        } else {
+            fprintf(stderr, "Invalid GTK monitor argument\n");
+        }
+    }
 }
 
 static void early_gtk_display_init(DisplayOptions *opts)
-- 
2.24.3



             reply	other threads:[~2021-06-17  2:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17  2:06 sweeaun [this message]
2021-06-18 11:07 ` [PATCH v2] ui/gtk: Allow user to select monitor number to display qemu in full screen through new gtk display option Markus Armbruster
2021-06-21  5:26   ` Khor, Swee Aun
2021-06-21  6:51     ` Gerd Hoffmann
2021-06-21  7:23       ` Khor, Swee Aun
2021-06-21 11:14         ` Gerd Hoffmann
2021-06-21 13:10           ` Khor, Swee Aun
2021-06-21  8:30       ` Markus Armbruster
2021-06-21  9:10         ` Khor, Swee Aun
2021-06-21 11:07         ` Gerd Hoffmann
2021-06-21  8:32     ` Markus Armbruster

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=20210617020609.18089-1-swee.aun.khor@intel.com \
    --to=swee.aun.khor@intel.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=khairul.anuar.romli@intel.com \
    --cc=qemu-devel@nongnu.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.