qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 4/4] gtk: set window ID


From: Daniel P. Berrange
Subject: Re: [Qemu-devel] [PATCH 4/4] gtk: set window ID
Date: Mon, 31 Oct 2016 16:59:58 +0000
User-agent: Mutt/1.7.1 (2016-10-04)

On Mon, Oct 31, 2016 at 05:00:07PM +0100, Samuel Thibault wrote:
> This uses the console API to record the window ID of the GTK windows.
> 
> Signed-off-by: Samuel Thibault <address@hidden>
> ---
>  ui/gtk.c | 25 +++++++++++++++++++++++--
>  1 file changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/ui/gtk.c b/ui/gtk.c
> index ca737c4..d75f255 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -2170,6 +2170,13 @@ void gtk_display_init(DisplayState *ds, bool 
> full_screen, bool grab_on_hover)
>      GtkDisplayState *s = g_malloc0(sizeof(*s));
>      char *filename;
>      GdkDisplay *window_display;
> +    GdkWindow *gdk_window;
> +#ifdef GDK_WINDOWING_X11
> +    Window window_id;
> +#elif defined(GDK_WINDOWING_WIN32)
> +    HWND window_id;
> +#endif
> +    int i;
>  
>      if (!gtkinit) {
>          fprintf(stderr, "gtk initialization failed\n");
> @@ -2232,8 +2239,6 @@ void gtk_display_init(DisplayState *ds, bool 
> full_screen, bool grab_on_hover)
>      {
>          VirtualConsole *cur = gd_vc_find_current(s);
>          if (cur) {
> -            int i;
> -
>              for (i = 0; i < s->nb_vcs; i++) {
>                  VirtualConsole *vc = &s->vc[i];
>                  if (vc && vc->type == GD_VC_VTE && vc != cur) {
> @@ -2253,6 +2258,22 @@ void gtk_display_init(DisplayState *ds, bool 
> full_screen, bool grab_on_hover)
>      }
>  
>      gd_set_keycode_type(s);
> +
> +    gdk_window = gtk_widget_get_window(s->window);
> +#ifdef GDK_WINDOWING_X11
> +    window_id = GDK_WINDOW_XID(gdk_window);
> +#elif defined(GDK_WINDOWING_WIN32)
> +    window_id = gdk_win32_window_get_impl_hwnd(gdk_window);
> +#endif

There are other GTK3 backends that may well be used - Wayland, Broadway
and Quartz. You can't use the compile time check on its own any more as
a single GTK can be built with multiple backends at once.

So to fully generalize you need
eg you'll need

    #ifdef GDK_WINDOWING_X11
    if (GDK_IS_X11_DISPLAY(dpy)) {
       ...
    }
    #endif

    #ifdef GDK_WINDOWING_WIN32
    if (GDK_IS_WIN32_DISPLAY(dpy)) {
       ...
    }
    #endif

    #ifdef GDK_WINDOWING_QUARTZ
    if (GDK_IS_QUARTZ_DISPLAY(dpy)) {
       ...
    }
    #endif

    ...and wayland, broadway...

> +    for (i = 0; ; i++) {
> +        /* All consoles share the same window */
> +        QemuConsole *con = qemu_console_lookup_by_index(i);
> +        if (con) {
> +            qemu_console_set_window_id(i, (int) window_id);
> +        } else {
> +            break;
> +        }
> +    }

If neither X11 or Win32 backends are defined, this will error
since window_id will not be declared.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|



reply via email to

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