From: Edmund Raile via <qemu-devel@nongnu.org>
To: qemu-devel@nongnu.org, marcandre.lureau@redhat.com, philmd@linaro.org
Cc: dongwon.kim@intel.com, hikalium@hikalium.com, thuth@redhat.com
Subject: [PATCH] UI/GTK: full-screen after wait for hiding of tabs and menu_bar
Date: Sat, 02 Nov 2024 04:04:24 +0000 [thread overview]
Message-ID: <a3f5c533b761756e90e80cc616e2e9dff3aefa4a.camel@proton.me> (raw)
Wait for hiding of GTK notebook tabs and GTK menu_bar before entering
full-screen due to asynchronous nature of GTK.
prevent:
* full-screen window overlap onto monitor below
* black bar on top of full-screen guest display
* misallignment of host-drawn guest cursor and invisible guest cursor
Signed-off-by: Edmund Raile <edmund.raile@proton.me>
---
I'd like to report an issue with GTK UI and suggest a solution for it.
When entering full-screen, the tabs and menu_bar need to be hidden.
Currently, gd_menu_full_screen() does all of this in-line but since
GTK operates asynchronously, this results in:
* a full-screen window that overlaps onto the monitor below
* a full-screen guest display that has a black bar above it
* a guest cursor that is misalligned to the
host cursor the GTK UI draws in-style of the guest cursor (QXL vga)
My solution is to wait for GTK to hide tabs and menu_bar,
and only then enter full screen.
I've implemented this with a callback on a simple 10ms timer.
It has been tested to work reliably under heavy CPU load, when
GTK may take longer to respond to requests.
Since gtk.c currently has no maintainer, I am uncertain who to submit
this patch to.
Kind regards,
Edmund Raile.
ui/gtk.c | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index bf9d3dd679..2f6aac6386 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1463,6 +1463,32 @@ static void gd_accel_show_menubar(void *opaque)
gtk_menu_item_activate(GTK_MENU_ITEM(s->show_menubar_item));
}
+static gboolean full_screen_enter_callback(gpointer user_data)
+{
+ GtkDisplayState *s = user_data;
+ VirtualConsole *vc = gd_vc_find_current(s);
+
+ gboolean tabs_visible = gtk_notebook_get_show_tabs(
+ GTK_NOTEBOOK(s->notebook));
+ gboolean menu_bar_visible = gtk_widget_get_visible(s->menu_bar);
+
+ if (!tabs_visible && !menu_bar_visible) {
+ gtk_window_fullscreen(GTK_WINDOW(s->window));
+ s->full_screen = TRUE;
+
+ gd_update_windowsize(vc);
+
+ /** deactivate callback **/
+ return FALSE;
+ } else {
+ /*
+ * re-schedule callback if GTK _still_
+ * did not manage to hide tabs and menu_bar
+ */
+ return TRUE;
+ }
+}
+
static void gd_menu_full_screen(GtkMenuItem *item, void *opaque)
{
GtkDisplayState *s = opaque;
@@ -1474,8 +1500,11 @@ static void gd_menu_full_screen(GtkMenuItem
*item, void *opaque)
if (vc->type == GD_VC_GFX) {
gtk_widget_set_size_request(vc->gfx.drawing_area, -1, -1);
}
- gtk_window_fullscreen(GTK_WINDOW(s->window));
- s->full_screen = TRUE;
+
+ gd_update_windowsize(vc);
+
+ /** give GTK 10ms to perform the resize **/
+ g_timeout_add(10, full_screen_enter_callback, s);
} else {
gtk_window_unfullscreen(GTK_WINDOW(s->window));
gd_menu_show_tabs(GTK_MENU_ITEM(s->show_tabs_item), s);
--
2.47.0
next reply other threads:[~2024-11-02 4:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-02 4:04 Edmund Raile via [this message]
2024-11-04 7:44 ` [PATCH] UI/GTK: full-screen after wait for hiding of tabs and menu_bar Marc-André Lureau
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=a3f5c533b761756e90e80cc616e2e9dff3aefa4a.camel@proton.me \
--to=qemu-devel@nongnu.org \
--cc=dongwon.kim@intel.com \
--cc=edmund.raile@proton.me \
--cc=hikalium@hikalium.com \
--cc=marcandre.lureau@redhat.com \
--cc=philmd@linaro.org \
--cc=thuth@redhat.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).