[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] ui/gtk: mon_num parameter to specify target monitor for laun

From: Paolo Bonzini
Subject: Re: [PATCH] ui/gtk: mon_num parameter to specify target monitor for launching Qemu
Date: Fri, 19 Nov 2021 10:24:08 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0

On 11/18/21 23:51, Dongwon Kim wrote:
+# @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

There is no need to accept -1; the opts->u.gtk struct uses a separate boolean field to indicate the default. Instead, the parameter should be an unsigned integer ("uint32").

Also please use "monitor", not "mon-num".  We usually avoid abbreviations.

+    if (opts->u.gtk.has_mon_num && opts->u.gtk.mon_num &&
+        opts->u.gtk.mon_num >= 0) {

Rejecting 0 ("opts->u.gtk.mon_num") is incorrect. If you declare it as unsigned, you can just use "if (opts->u.gtk.has_mon_num").



+        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) {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]